diff --git a/source/nostril/app.d b/source/nostril/app.d index ca96121..7cd372e 100644 --- a/source/nostril/app.d +++ b/source/nostril/app.d @@ -1,20 +1,8 @@ module nostril.app; -import std.stdio; - -import vibe.vibe; -import vibe.http.dist; -import std.json; - -import gogga; - -// TODO: Investigate if we need the belowe (I copied it from Birchwood) -__gshared GoggaLogger logger; -__gshared static this() -{ - logger = new GoggaLogger(); -} +import nostril.logging : LoggerSetup; +mixin LoggerSetup!(); import nostril.server; void main() diff --git a/source/nostril/logging.d b/source/nostril/logging.d new file mode 100644 index 0000000..dc8d824 --- /dev/null +++ b/source/nostril/logging.d @@ -0,0 +1,18 @@ +module nostril.logging; + +mixin template LoggerSetup() +{ + import gogga; + + // TODO: Investigate if we need the belowe (I copied it from Birchwood) + __gshared GoggaLogger logger; + __gshared static this() + { + logger = new GoggaLogger(); + + version(dbg) + { + logger.enableDebug(); + } + } +} \ No newline at end of file diff --git a/source/nostril/server.d b/source/nostril/server.d index a0ce188..7456a2c 100644 --- a/source/nostril/server.d +++ b/source/nostril/server.d @@ -1,13 +1,14 @@ module nostril.server; +import nostril.logging; + + +/** + * FIXME: Fix the below so I need not import gogga too + */ +mixin LoggerSetup!(); import gogga; -// TODO: Investigate if we need the belowe (I copied it from Birchwood) -__gshared GoggaLogger logger; -__gshared static this() -{ - logger = new GoggaLogger(); -} import core.thread : Thread; @@ -102,7 +103,9 @@ public class Server */ public final void addConnection(Connection newConnection) { + logger.dbg("Adding connection '"~newConnection.toString()~"'...\n", DebugType.WARNING); connections[newConnection] = newConnection; + logger.dbg("Adding connection '"~newConnection.toString()~"'... [done]\n", DebugType.WARNING); } /** @@ -113,7 +116,9 @@ public class Server */ public final void delConnection(Connection existingConnection) { + logger.dbg("Removing connection '"~existingConnection.toString()~"'...\n", DebugType.WARNING); connections.remove(existingConnection); + logger.dbg("Removing connection '"~existingConnection.toString()~"'... [done]\n", DebugType.WARNING); } }