mirror of https://github.com/deavmi/gogga.git
- Adding transform modes
This commit is contained in:
parent
7652938043
commit
7ad503825f
|
@ -3,12 +3,24 @@ module gogga.transform;
|
|||
import dlog;
|
||||
import gogga.context;
|
||||
|
||||
// TODO: hehe easter egg TRADITIONAL, LIBERAL, UNHINGED
|
||||
public enum GoggaMode
|
||||
{
|
||||
SIMPLE,
|
||||
TwoKTwenty3,
|
||||
RUSTACEAN
|
||||
}
|
||||
|
||||
public class GoggaTransform : MessageTransform
|
||||
{
|
||||
private bool isSourceMode = false;
|
||||
private GoggaMode mode;
|
||||
|
||||
public override string transform(string text, Context ctx)
|
||||
{
|
||||
/* The generated output string */
|
||||
string finalOutput;
|
||||
|
||||
|
||||
/* Get the GoggaContext */
|
||||
GoggaContext gCtx = cast(GoggaContext)ctx;
|
||||
|
||||
|
@ -16,13 +28,41 @@ public class GoggaTransform : MessageTransform
|
|||
CompilationInfo compInfo = gCtx.getLineInfo();
|
||||
string[] context = compInfo.toArray();
|
||||
|
||||
/* Module information (and status debugColoring) */
|
||||
string moduleInfo = cast(string)debugColor("["~context[1]~"]", gCtx.getLevel());
|
||||
|
||||
/* Function and line number info */
|
||||
string funcInfo = cast(string)(colorSrc("("~context[4]~":"~context[2]~")"));
|
||||
/* Extract the Level */
|
||||
Level level = gCtx.getLevel();
|
||||
|
||||
return moduleInfo~" "~funcInfo~" "~text~"\n";
|
||||
|
||||
// TODO: go for [<LEVEL>] (<filePath>/<functionName>:<lineNumber>) <message>
|
||||
|
||||
/**
|
||||
* Simple mode is just: `[<LEVEL>] <message>`
|
||||
*/
|
||||
if(mode == GoggaMode.SIMPLE)
|
||||
{
|
||||
finalOutput = cast(string)debugColor("["~to!(string)(level)~"] "~text);
|
||||
}
|
||||
/**
|
||||
* TwoKTwenty3 is: `[<file>] (<module>:<lineNumber>) <message>`
|
||||
*/
|
||||
else if(mode == Gogga.TwoKTwenty3)
|
||||
{
|
||||
/* Module information (and status debugColoring) */
|
||||
string moduleInfo = cast(string)debugColor("["~context[1]~"]", level);
|
||||
|
||||
/* Function and line number info */
|
||||
string funcInfo = cast(string)(colorSrc("("~context[4]~":"~context[2]~")"));
|
||||
|
||||
finalOutput = moduleInfo~" "~funcInfo~" "~text~"\n";
|
||||
}
|
||||
/**
|
||||
* Rustacean mode
|
||||
*/
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return finalOutput;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue