Skip to content

Commit

Permalink
Merge pull request #1 from deavmi/rustacena_simple
Browse files Browse the repository at this point in the history
Add simpler logger type
  • Loading branch information
deavmi authored Nov 22, 2023
2 parents 034b4ce + e74f906 commit c66689d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
21 changes: 21 additions & 0 deletions source/gogga/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ unittest
gLogger.enableDebug();
gLogger.dbg("This is a VISIBLE debug", true);

// Make space between unit tests
writeln();
}

unittest
{
GoggaLogger gLogger = new GoggaLogger();
gLogger.mode(GoggaMode.RUSTACEAN_SIMPLE);

// Test the normal modes
gLogger.info("This is an info message");
gLogger.warn("This is a warning message");
gLogger.error("This is an error message");

// We shouldn't see anything as debug is off
gLogger.dbg("This is a debug which is hidden", 1);

// Now enable debugging and you should see it
gLogger.enableDebug();
gLogger.dbg("This is a VISIBLE debug", true);

// Make space between unit tests
writeln();
}
18 changes: 16 additions & 2 deletions source/gogga/transform.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ public enum GoggaMode
/**
* Rustacean mode is: `[<LEVEL>] (<filePath>/<functionName>:<lineNumber>) <message>`
*/
RUSTACEAN
RUSTACEAN,

/**
* Simple rustacean mode is: `[<LEVEL>] (<functionName>:<lineNumber>) <message>`
*/
RUSTACEAN_SIMPLE
}

/**
Expand Down Expand Up @@ -89,12 +94,21 @@ public class GoggaTransform : MessageTransform
/**
* Rustacean mode is: `[<LEVEL>] (<filePath>/<functionName>:<lineNumber>) <message>`
*/
else
else if(mode == GoggaMode.RUSTACEAN)
{
finalOutput = cast(string)debugColor(to!(string)(level)~"\t", level);
finalOutput ~= cast(string)(colorSrc(context[1]~"/"~context[4]~":"~context[2]~" "));
finalOutput ~= text~"\n";
}
/**
* Simple rustacean mode is: `[<LEVEL>] (<functionName>:<lineNumber>) <message>`
*/
else if(mode == GoggaMode.RUSTACEAN_SIMPLE)
{
finalOutput = cast(string)debugColor(to!(string)(level)~"\t", level);
finalOutput ~= cast(string)(colorSrc(context[4]~":"~context[2]~" "));
finalOutput ~= text~"\n";
}

return finalOutput;
}
Expand Down

0 comments on commit c66689d

Please sign in to comment.