Logger

The logger is the core component of SLF4D. Use it to generate log messages in your code. An ad-hoc Logger can be created and used anywhere, but usually you'll want to use the getLogger() function to obtain a pre-configured Logger that has been set up with an application-specific LogHandler.

Note that the D language offers some special keywords like __MODULE__ and __PRETTY_FUNCTION__ which at compile time resolve to the respective source symbols, and are used heavily here for adding context to log messages. Because these must be resolved in the actual source location and *not* in the logger's own code, we make use of default values for most logging functions. Functions will usually end with a list of arguments that default to these keywords, and you shouldn't need to ever provide a value for these.

Constructors

this
this(LogHandler handler, Level level, string name)

Initializes a new logger. Usually, you won't use this constructor, and instead, you should obtain a Logger via loggerFactory.getLogger().

Members

Functions

builder
LogBuilder builder()

Gets a builder that can be used to fluently build a log message.

log
void log(LogMessage msg)

Logs a message. Only messages whose level is greater than or equal to this logger's level will be logged.

log
void log(Level level, string msg, Exception exception, string moduleName, string functionName, string fileName, size_t lineNumber)

Logs a message.

log
void log(Level level, Exception exception, string moduleName, string functionName, string fileName, size_t lineNumber)

Logs an exception message. It creates a basic message string formatted like "ExceptionName: message".

logF
void logF(Level level, T args, Exception exception, string moduleName, string functionName, string fileName, size_t lineNumber)

Logs a formatted string message.