mirror of
https://github.com/deavmi/nostril
synced 2024-09-20 06:03:12 +02:00
Logging
- Placed most of logging setup into a mixin template called `LoggerSetup` App - Use the new `LoggerSetup` mixin Server - Use the new `LoggerSetup` mixin
This commit is contained in:
parent
d453c16ad5
commit
4c8a57eb1d
@ -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()
|
||||
|
18
source/nostril/logging.d
Normal file
18
source/nostril/logging.d
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user