-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added logging facilities
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Internal logging facilities | ||
*/ | ||
module birchwood.logging; | ||
|
||
import gogga; | ||
import gogga.extras; | ||
import dlog.basic : Level, FileHandler; | ||
import std.stdio : stdout; | ||
|
||
/** | ||
* Globally available logger | ||
*/ | ||
package __gshared GoggaLogger logger; | ||
|
||
/** | ||
* Initializes a logger instance | ||
* globally | ||
*/ | ||
__gshared static this() | ||
{ | ||
logger = new GoggaLogger(); | ||
|
||
GoggaMode mode; | ||
|
||
// TODO: Add flag support | ||
version(DBG_VERBOSE_LOGGING) | ||
{ | ||
mode = GoggaMode.RUSTACEAN; | ||
} | ||
else | ||
{ | ||
mode = GoggaMode.SIMPLE; | ||
} | ||
|
||
logger.mode(mode); | ||
|
||
Level level = Level.DEBUG; | ||
|
||
// TODO: Add flag support | ||
// version(DBG_DEBUG_LOGGING) | ||
// { | ||
// level = Level.DEBUG; | ||
// } | ||
// else | ||
// { | ||
// level = Level.INFO; | ||
// } | ||
|
||
|
||
logger.setLevel(level); | ||
logger.addHandler(new FileHandler(stdout)); | ||
} | ||
|
||
// Bring in helper methods | ||
mixin LoggingFuncs!(logger); |