generateStyle

Utility mixin template that generates facilities for output message formatting for console output and file output.

Style parameter defines what type is used as logging level. It must be an enum. Order of values defines behavior of muting (styles that less current low border aren't printed to output).

First value of Args could be a function/delegate for customizing time formatting. It should have return type of string and parameters of (DistType t, SysTime time). Where t tells when function/delegate is called to format output to file or console, time is a time that should be converted to string.

Rest part of $(Args) has format of list of triples (Style value, string, string). Style value defines for which logging level following format strings are. First format string is used for console output, the second one is for file output.

Format strings could use two arguments: '%1$s' is message that is passed to a logger and '%2$s' is current time string. Formatting is handled by std.format module.

Members

Aliases

Params
alias Params = ParameterTypeTuple!timeFormat
Undocumented in source.
RetT
alias RetT = ReturnType!timeFormat
Undocumented in source.
TS
alias TS = Args[1..$]
Undocumented in source.
TS
alias TS = Args
Undocumented in source.
timeFormat
alias timeFormat = Args[0]
Undocumented in source.

Functions

formatConsoleOutput
string formatConsoleOutput(string message, Style level)
Undocumented in source. Be warned that the author may not have intended to support it.
formatFileOutput
string formatFileOutput(string message, Style level)
Undocumented in source. Be warned that the author may not have intended to support it.
timeFormat
string timeFormat(DistType t, SysTime time)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

Example of default style

import dlogg.log;
mixin generateStyle!(LoggingLevel
            , LoggingLevel.Debug,   "Debug: %1$s",   "[%2$s] Debug: %1$s"
            , LoggingLevel.Notice,  "Notice: %1$s",  "[%2$s] Notice: %1$s"
            , LoggingLevel.Warning, "Warning: %1$s", "[%2$s] Warning: %1$s"
            , LoggingLevel.Fatal,   "Fatal: %1$s",   "[%2$s] Fatal: %1$s"
            , LoggingLevel.Muted,   "",              ""
            );

Meta