Logger

This class is the base of every logger. In order to create a new kind of logger a deriving class needs to implement the writeLogMsg method. By default this is not thread-safe.

It is also possible to override the three methods beginLogMsg, logMsgPart and finishLogMsg together, this option gives more flexibility.

abstract
class Logger {
protected
Appender!string msgAppender;
protected
LogEntry header;
}

Constructors

this
this(LogLevel lv)

Every subclass of Logger has to call this constructor from their constructor. It sets the LogLevel, and creates a fatal handler. The fatal handler will throw an Error if a log call is made with level LogLevel.fatal.

Members

Aliases

critical
alias critical = memLogFunctions!(LogLevel.critical).logImpl
criticalf
alias criticalf = memLogFunctions!(LogLevel.critical).logImplf
error
alias error = memLogFunctions!(LogLevel.error).logImpl
errorf
alias errorf = memLogFunctions!(LogLevel.error).logImplf
fatal
alias fatal = memLogFunctions!(LogLevel.fatal).logImpl
fatalf
alias fatalf = memLogFunctions!(LogLevel.fatal).logImplf
info
alias info = memLogFunctions!(LogLevel.info).logImpl
infof
alias infof = memLogFunctions!(LogLevel.info).logImplf
trace
alias trace = memLogFunctions!(LogLevel.trace).logImpl
tracef
alias tracef = memLogFunctions!(LogLevel.trace).logImplf
warning
alias warning = memLogFunctions!(LogLevel.warning).logImpl
warningf
alias warningf = memLogFunctions!(LogLevel.warning).logImplf

This template provides the log functions for the Logger class with the LogLevel encoded in the function name.

Functions

finishLogMsg
void finishLogMsg()

Signals that the message has been written and no more calls to logMsgPart follow.

forwardMsg
void forwardMsg(LogEntry payload)

This method allows forwarding log entries from one logger to another.

log
void log(LogLevel ll, bool condition, A args)
void log(LogLevel ll, bool condition, T args, int line, string file, string funcName, string prettyFuncName)

This method logs data with the LogLevel of the used Logger.

log
void log(LogLevel ll, A args)
void log(LogLevel ll, T args, int line, string file, string funcName, string prettyFuncName, string moduleName)

This function logs data to the used Logger with a specific LogLevel.

log
void log(bool condition, A args)
void log(bool condition, T args, int line, string file, string funcName, string prettyFuncName, string moduleName)

This function logs data to the used Logger depending on a explicitly passed condition with the LogLevel of the used Logger.

log
void log(A args)
void log(T arg, int line, string file, string funcName, string prettyFuncName, string moduleName)

This function logs data to the used Logger with the LogLevel of the used Logger.

logMsgPart
void logMsgPart(const(char)[] msg)

Logs a part of the log message.

logf
void logf(LogLevel ll, bool condition, string msg, A args)

This function logs data to the used Logger with a specific LogLevel and depending on a condition in a printf-style manner.

logf
void logf(LogLevel ll, string msg, A args)

This function logs data to the used Logger with a specific LogLevel in a printf-style manner.

logf
void logf(bool condition, string msg, A args)

This function logs data to the used Logger depending on a condition with the LogLevel of the used Logger in a printf-style manner.

logf
void logf(string msg, A args)

This method logs data to the used Logger with the LogLevel of the this Logger in a printf-style manner.

writeLogMsg
void writeLogMsg(LogEntry payload)

A custom logger must implement this method in order to work in a MultiLogger and ArrayLogger.

Properties

fatalHandler
void delegate() fatalHandler [@property getter]
void delegate() @(safe) fatalHandler [@property setter]

This delegate is called in case a log message with LogLevel.fatal gets logged.

logLevel
LogLevel logLevel [@property getter]
LogLevel logLevel [@property setter]

The LogLevel determines if the log call are processed or dropped by the Logger. In order for the log call to be processed the LogLevel of the log call must be greater or equal to the LogLevel of the logger.

Structs

LogEntry
struct LogEntry

LogEntry is a aggregation combining all information associated with a log message. This aggregation will be passed to the method writeLogMsg.

Templates

memLogFunctions
template memLogFunctions(LogLevel ll)

This template provides the log functions for the Logger class with the LogLevel encoded in the function name.

Meta