des.log

Simple example

import des.log;

void func()
{
    logger.fatal( "fatal" );
    logger.error( "error" );
    logger.warn( "warn" );
    logger.info( "info" );
    logger.Debug( "debug" );
    logger.trace( "trace" );
}

void main()
{
    logger.fatal( "fatal message" );
    logger.error( "error message" );
    logger.warn( "warn message" );
    logger.info( "info message" );
    logger.Debug( "debug message" );
    logger.trace( "trace message" );

    func();
}

can have output like this:

./app
[000000.000122258][FATAL][app.main]: fatal message
[000000.000214030][ERROR][app.main]: error message
[000000.000261067][FATAL][app.func]: fatal
[000000.000285349][ERROR][app.func]: error
More...

Modules

base
module des.log.base
Undocumented in source.
logcls
module des.log.logcls
Undocumented in source.
output
module des.log.output
Undocumented in source.
rule
module des.log.rule
Undocumented in source.

Public Imports

des.log.base
public import des.log.base;
Undocumented in source.
des.log.logcls
public import des.log.logcls;
Undocumented in source.
des.log.rule
public import des.log.rule;
Undocumented in source.
des.log.output
public import des.log.output;
Undocumented in source.

Members

Mixin templates

ClassLogger
mixintemplate ClassLogger()

for simple adding logging to class

Variables

logger
Logger logger;
logger_getopt_result
GetoptResult logger_getopt_result;
Undocumented in source.

Detailed Description

Flag --log used for setting max level of logging output. Default level is error. If log function called with greater level it's skipped. Level has attitudes off < fatal < error < warn < info < debug < trace.

$ ./app --log app.func:debug
[log use min]: false
[log rules]:
ERROR
app : ERROR
   func : DEBUG
[000000.000162889][FATAL][app.main]: fatal message
[000000.000207483][ERROR][app.main]: error message
[000000.000242506][FATAL][app.func]: fatal
[000000.000261887][ERROR][app.func]: error
[000000.000285754][ WARN][app.func]: warn
[000000.000304789][ INFO][app.func]: info
[000000.000323652][DEBUG][app.func]: debug
$ ./app --log info --log app.func:trace
[log use min]: false
[log rules]:
INFO
app : INFO
   func : TRACE
[000000.000245525][FATAL][app.main]: fatal message
[000000.000308796][ERROR][app.main]: error message
[000000.000338714][ WARN][app.main]: warn message
[000000.000365555][ INFO][app.main]: info message
[000000.000406501][FATAL][app.func]: fatal
[000000.000434482][ERROR][app.func]: error
[000000.000461296][ WARN][app.func]: warn
[000000.000487242][ INFO][app.func]: info
[000000.000512884][DEBUG][app.func]: debug
[000000.000538288][TRACE][app.func]: trace

Flag --log can be used with module name ./program --log draw.point:debug. It will set debug level for module draw.point and default to other.

Flag --log-use-min is boolean flag. It forces logging system to skip output from all child modules if their level greater than parent. Default is false.

./program --log trace --log draw:info --log draw.point:trace --log-use-min=true skips all output from logger.trace and logger.Debug from whole draw.point, and doesn't skip from other modules.

./program --log trace --log draw:info --log draw.point:trace allow log_trace and log_debug only from draw.point from module draw. For other modules in draw sets level info

You can compile program with version=des_log_onlyerror for skip all trace, debug, info and warn outputs in logger. It can improve program release speed.

Class logging

Module provides some functional for useful logging classes.

Examples

module x;
import des.log;
class A
{
    mixin ClassLogger;
    void func() { logger.trace( "hello" ); }
}
module y;
import x;
class B : A { }
auto b = new B;
b.func();

outputs:

[000000.148628473][TRACE][x.A.func]: hello

If create instance logger

class B : A { this(){ logger = new InstanceLogger(this); } }

outputs:

[000000.148628473][TRACE][y.B.func]: hello

If create instance logger with instance name

class B : A { this(){ logger = new InstanceLogger(this,"my object"); } }

outputs:

[000000.148628473][TRACE][y.B.[my object].func]: hello

If create instance full logger

class B : A { this(){ logger = new InstanceFullLogger(this); } }

outputs:

[000000.148628473][TRACE][y.B.[x.A.func]]: hello

If create instance full logger with name

class B : A { this(){ logger = new InstanceFullLogger(this,"name"); } }

outputs:

[000000.148628473][TRACE][y.B.[name].[x.A.func]]: hello

Flag --log can get full emitter string y.B.[name].[x.A.func].

./program --log "y.B.[one]:trace" --log "y.B.[two]:debug"

Meta