dlogg.style

Module defines facilities for custom styling of logger messages. Template mixin $(generateStyle) generates code for your logging styles (represented by an enum) that can be mixed into logger implementation. * See generateStyle for detailed description. * Example of default logger style:

1    import dlogg.log, dlogg.style;
2 *
3    mixin generateStyle!(LoggingLevel
4                , LoggingLevel.Debug,   "Debug: %1$s",   "[%2$s] Debug: %1$s"
5                , LoggingLevel.Notice,  "Notice: %1$s",  "[%2$s] Notice: %1$s"
6                , LoggingLevel.Warning, "Warning: %1$s", "[%2$s] Warning: %1$s"
7                , LoggingLevel.Fatal,   "Fatal: %1$s",   "[%2$s] Fatal: %1$s"
8                , LoggingLevel.Muted,   "",              ""
9                );

*

Members

Enums

DistType
enum DistType

Enum type that is used in time formatting function in generateStyle. * Note: the type is exposed to allow user to implement its own time formatting functions. *

Mixin templates

generateStyle
mixin template generateStyle(Style, Args...)

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.

Meta

Authors

NCrashed <ncrashed@gmail.com>

License

Subject to the terms of the MIT license, as written in the included LICENSE file.