Skip to content

Commit

Permalink
Messages
Browse files Browse the repository at this point in the history
- Use new logging facility
  • Loading branch information
deavmi committed May 12, 2024
1 parent 613adf7 commit 7328d78
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions source/birchwood/protocol/messages.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,13 @@ import birchwood.protocol.constants : ReplyType;

import birchwood.client.exceptions;
import birchwood.config.conninfo : ChecksMode;
import birchwood.logging;

// TODO: Before release we should remove this import
import std.stdio : writeln;

/* TODO: We could move these all to `package.d` */

/* Static is redundant as module is always static , gshared needed */
/* Apparebky works without gshared, that is kinda sus ngl */
package __gshared Logger logger;
/**
* source/birchwood/messages.d(10,8): Error: variable `birchwood.messages.logger` is a thread-local class and cannot have a static initializer. Use `static this()` to initialize instead.
*
* It is complaining that it wopuld static init per thread, static this() for module is required but that would
* do a module init per thread, so __gshared static this() is needed, we want one global init - a single logger
* variable and also class init
*/

__gshared static this()
{
logger = new DefaultLogger();
}

/**
* Encoding/decoding primitives
*/
Expand Down Expand Up @@ -140,8 +125,8 @@ public final class Message
}
catch(ConvException e)
{
logger.log("<<< Unsupported response code (Error below) >>>");
logger.log(e);
DEBUG("<<< Unsupported response code (Error below) >>>");
DEBUG(e);
}
}

Expand Down Expand Up @@ -286,7 +271,7 @@ public final class Message
{
from = message[1..firstSpace];

// logger.log("from: "~from);
// DEBUG("from: "~from);

/* TODO: Find next space (what follows `from` is `' ' { ' ' }`) */
ulong i = firstSpace;
Expand All @@ -306,7 +291,7 @@ public final class Message

/* Extract the command */
command = rem[0..idx];
// logger.log("command: "~command);
// DEBUG("command: "~command);

/* Params are everything till the end */
i = idx;
Expand All @@ -318,12 +303,12 @@ public final class Message
}
}
params = rem[i..rem.length];
// logger.log("params: "~params);
// DEBUG("params: "~params);
}
else
{
//TODO: handle
logger.log("Malformed message start after :");
DEBUG("Malformed message start after :");
assert(false);
}

Expand Down

0 comments on commit 7328d78

Please sign in to comment.