Default synchronized log realization. The logging process performs instantly (if it can be processed properly). Logger puts message style string and current timestamp before the message.
Tested to be able operate in daemon mode and under heavy concurrent writing.
Standard implementation of IStyledLogger interface.
shared ILogger logger = new StrictLogger("my_awesome_log.log"); logger.minOutputLevel = LoggingLevel.Warning; // info msgs won't be printed in console logger.logInfo("Info message!"); logger.logError("Error message!"); logger.logDebug("Debug message!"); // received USR1 signal from logrotate logger.reload;
Implementation of IStyledLogger with custom style. Usually you want to use StrictLogger alias, but there are cases where you want custom styles.
Example of custom styled logger:
enum MyLevel { Error, Debug } alias MyLogger = StyledStrictLogger!(MyLevel , MyLevel.Debug, "Debug: %1$s", "[%2$s] Debug: %1$s" , MyLevel.Error, "Fatal: %1$s", "[%2$s] Fatal: %1$s");
Option how to open logging file
Log file name.
Setting new log file name. If the value differs from old one, logger should close old one and open new file.
Prints message into log. Displaying in the console controlled by minOutputLevel property.
Setups minimum log level,
Setups minimum message level that goes to file.
Setups minimum message level that goes to file.
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.
Creates log at dir/name. Tries to create parent directory and all sub directories.
Tries to create log file at location.
Unsafe write down the message without any meta information.
Used to manual shutdown protocols.