Code Monkey home page Code Monkey logo

dlogg's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dlogg's Issues

logger.reload() is not usable in a signal handler

Tried to reload the log file on USR1 signal:

import core.stdc.signal;
enum SIGUSR1 = 10;
signal(SIGUSR1, function void() @system nothrow @nogc {
    logger.reload();
});

This code failed to compile:

source/log.d(56,16): Error: @nogc function 'log._sharedStaticCtor11.__funcliteral1' cannot call non-@nogc function 'dlogg.strict.StyledStrictLogger!(LogLevel, cast(LogLevel)0, "[%2$s]: \x1b[95mDebug:\x1b[0m %1$s", "[%2$s]: Debug: %1$s", cast(LogLevel)1, "[%2$s]: \x1b[92mInfo:\x1b[0m %1$s", "[%2$s]: Info: %1$s", cast(LogLevel)2, "[%2$s]: \x1b[93mWarning:\x1b[0m %1$s", "[%2$s]: Warning: %1$s", cast(LogLevel)3, "[%2$s]: \x1b[91mError:\x1b[0m %1$s", "[%2$s]: Error: %1$s", cast(LogLevel)4, "[%2$s]: \x1b[1m\x1b[91mFatal:\x1b[0m\x1b[0m %1$s", "[%2$s]: Fatal: %1$s", cast(LogLevel)5, "", "").StyledStrictLogger.reload'
source/log.d(56,16): Error: function `dlogg.strict.StyledStrictLogger!(LogLevel, cast(LogLevel)0, "[%2$s]: \x1b[95mDebug:\x1b[0m %1$s", "[%2$s]: Debug: %1$s", cast(LogLevel)1, "[%2$s]: \x1b[92mInfo:\x1b[0m %1$s", "[%2$s]: Info: %1$s", cast(LogLevel)2, "[%2$s]: \x1b[93mWarning:\x1b[0m %1$s", "[%2$s]: Warning: %1$s", cast(LogLevel)3, "[%2$s]: \x1b[91mError:\x1b[0m %1$s", "[%2$s]: Error: %1$s", cast(LogLevel)4, "[%2$s]: \x1b[1m\x1b[91mFatal:\x1b[0m\x1b[0m %1$s", "[%2$s]: Fatal: %1$s", cast(LogLevel)5, "", "").StyledStrictLogger.reload` is not nothrow
source/log.d(55,21): Error: nothrow function `log._sharedStaticCtor11.__funcliteral1` may throw

Indeed, it's neither nothrow nor @nogc, but it should be. To my suprise, even the function std.file.exists, which is used by reload is not @nogc, since it allocates temporary strings for paths. I could just declare the signal function myself and change the signature of the signal handler, but it would be asking for trouble. OS doesn't ask politely when a signal arrives, it just interrupts a random thread of the program to handle it. According to man 7 pthreads:

POSIX.1 distinguishes the notions of signals that are directed to the process as a whole and signals that are directed to individual threads. According to POSIX.1, a process-directed signal (sent using kill(2), for example) should be handled by a single, arbitrarily selected thread within the process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.