dlogg

Logging system designed to operate in concurrent application.

The system should be initialized with initLoggingSystem function. There is no need to call shutdown function as it is happen in module destructor.

Example:
void testThread()
{
    foreach(j; 1 .. 50)
    {
        logInfo(to!string(j));
        logError(to!string(j));
    }
}

foreach(i; 1 .. 50)
{
    spawn(&testThread);
}
License
Subject to the terms of the MIT license, as written in the included LICENSE file.
Authors
NCrashed

enum  LoggingLevel: int;

Log levels defines style of the messages. Printing in console can be controlled by ILogger.minOutputLevel property.


alias  ILogger = IStyledLogger!(LoggingLevel).IStyledLogger;

Default logger interface that uses LoggingLevel as enum that describes ordering of logging levels.


shared void  logDebug(E...)(shared ILogger logger, E args);

Wrapper for handy debug messages.

Warning:
main purpose for debug messages, thus it is not lazy.

void  logInfo(E...)(shared ILogger logger, E args);

Not lazy wrapper for multiple args messages


void  logInfo()(shared ILogger logger, lazy string message);

Lazy wrapper for one string message


void  logWarning(E...)(shared ILogger logger, E args);

Not lazy wrapper for multiple args messages


void  logWarning()(shared ILogger logger, lazy string message);

Lazy wrapper for one string message


void  logError(E...)(shared ILogger logger, E args);

Not lazy wrapper for multiple args messages


void  logError()(shared ILogger logger, lazy string message);

Lazy wrapper for one string message


interface  IStyledLogger(StyleEnum);

Interface for lazy logging. Assumes to be nothrow. Underlying realization should be concurrent safe.

StyleEnum is enum that used to distinct logging levels and define ordering for verbosity muting.


@property void  name(string value);

Setting new log file  name. If the value differs from old one, logger should close old one and open new file.


const @property string  name();

Log file  name.


void  log(lazy string message, StyleEnum level);

Prints message into  log. Displaying in the console controlled by minOutputLevel property.


const @property LoggingLevel  minOutputLevel();

Returns
minimum log level, will be printed in the console.

@property void  minOutputLevel(StyleEnum level);

Setups minimum message level that goes to console.


@property LoggingLevel  minLoggingLevel();

Setups minimum message level that goes to file.


@property void  minLoggingLevel(StyleEnum level);

Setups minimum message level that goes to file.


void  finalize();

Used to manual shutdown protocols.


void  rawInput(string message);

Unsafe write down the message without any meta information.


string  formatConsoleOutput(string message, StyleEnum level);

Format message with default logging style (etc. time and level string).


string  formatFileOutput(string message, StyleEnum level);

Format message with default logging style (etc. time and level string).


void  reload();

Checks if the log file is exists at specified location and if can't find it, recreates the file and continues write into it.

Useful for logrotate utility. GNU/Linux system checks file identity by inode, that doesn't change while renaming. Thus after renaming the file at location log continues write into the renamed file. The call to the  reload method force splitting log into two parts.

Note:
The method is not nothrow!