Skip to content

Commit

Permalink
birchwood.logging
Browse files Browse the repository at this point in the history
- Added logging facilities
  • Loading branch information
deavmi committed May 12, 2024
1 parent dfbee88 commit be8ccbe
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions source/birchwood/logging.d
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);

0 comments on commit be8ccbe

Please sign in to comment.