1 /**
2  * Build-argument customizable mixin
3  * that provides, whicever module
4  * imports it, with var-arg logging
5  * functions `DEBUG(...)`, `INFO(...)`,
6  * `WARN(...)` and `ERROR(...)`.
7  *
8  * Authors: Tristan Brice Velloza Kildaire
9  */
10 module gogga.mixins;
11 
12 import gogga;
13 import gogga.extras;
14 import dlog.basic : Level, FileHandler;
15 import std.stdio : stdout;
16 
17 /**
18  * The logger instance
19  * shared amongst a single
20  * thread (TLS)
21  */
22 private GoggaLogger logger;
23 
24 /**
25  * Initializes a logger instance
26  * per thread (TLS)
27  */
28 static this()
29 {
30     logger = new GoggaLogger();
31 
32     GoggaMode mode;
33     
34     version(DBG_VERBOSE_LOGGING)
35     {
36         mode = GoggaMode.RUSTACEAN;
37     }
38     else
39     {
40         mode = GoggaMode.SIMPLE;
41     }
42 
43     logger.mode(mode);
44 
45     Level level;
46 
47     version(DBG_DEBUG_LOGGING)
48     {
49         level = Level.DEBUG;
50     }
51     else
52     {
53         level = Level.INFO;
54     }
55 
56     logger.setLevel(level);
57     logger.addHandler(new FileHandler(stdout));
58 }
59 
60 // Bring in helper methods
61 mixin LoggingFuncs!(logger);