mirror of https://github.com/deavmi/gogga.git
Idk
This commit is contained in:
parent
bfff52be39
commit
1c7dbfe29f
|
@ -273,16 +273,41 @@ public final class GoggaLogger : BasicLogger
|
||||||
/* Set the level */
|
/* Set the level */
|
||||||
message.setLevel(level);
|
message.setLevel(level);
|
||||||
|
|
||||||
|
|
||||||
|
/* Flattened compile-time arguments */
|
||||||
|
string[] flattened;
|
||||||
|
|
||||||
// TODO: Add a feature (compile time check)
|
// TODO: Add a feature (compile time check)
|
||||||
// that if segments is first string then everything else
|
// that if segments is first string then everything else
|
||||||
// iets anders, then apply formatting
|
// iets anders, then apply formatting
|
||||||
|
static if(segments.length > 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
static if(__traits(isSame, typeof(segments[0]), string))
|
||||||
|
{
|
||||||
|
string fmtString = segments[0];
|
||||||
|
|
||||||
|
// What about info("Hello", 2)
|
||||||
|
// well we could try ands scan
|
||||||
|
// and see if it is a format string?
|
||||||
|
import std.string : format;
|
||||||
|
string formatted = format(fmtString, segments[1..$]);
|
||||||
|
|
||||||
|
flattened = [formatted];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flattened = flatten(segments);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab all compile-time arguments and make them
|
* Grab all compile-time arguments and make them
|
||||||
* into an array, then join them together and
|
* into an array, then join them together and
|
||||||
* set that text as the message's text
|
* set that text as the message's text
|
||||||
*/
|
*/
|
||||||
message.setText(join(flatten(segments), " "));
|
message.setText(join(flattened, " "));
|
||||||
|
|
||||||
/* Log this message */
|
/* Log this message */
|
||||||
log(message);
|
log(message);
|
||||||
|
@ -475,7 +500,7 @@ unittest
|
||||||
gLogger.error("This is an error message");
|
gLogger.error("This is an error message");
|
||||||
|
|
||||||
// We shouldn't see anything as debug is off
|
// We shouldn't see anything as debug is off
|
||||||
gLogger.dbg("This is a debug which is hidden", 1);
|
gLogger.dbg("This is a debug which is hidden %d", 1);
|
||||||
|
|
||||||
// Now enable debugging and you should see it
|
// Now enable debugging and you should see it
|
||||||
gLogger.setLevel(Level.DEBUG);
|
gLogger.setLevel(Level.DEBUG);
|
||||||
|
|
Loading…
Reference in New Issue