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 dlog;
|
||||||
import gogga.context;
|
import gogga.context;
|
||||||
|
|
||||||
|
// TODO: hehe easter egg TRADITIONAL, LIBERAL, UNHINGED
|
||||||
|
public enum GoggaMode
|
||||||
|
{
|
||||||
|
SIMPLE,
|
||||||
|
TwoKTwenty3,
|
||||||
|
RUSTACEAN
|
||||||
|
}
|
||||||
|
|
||||||
public class GoggaTransform : MessageTransform
|
public class GoggaTransform : MessageTransform
|
||||||
{
|
{
|
||||||
private bool isSourceMode = false;
|
private GoggaMode mode;
|
||||||
|
|
||||||
public override string transform(string text, Context ctx)
|
public override string transform(string text, Context ctx)
|
||||||
{
|
{
|
||||||
|
/* The generated output string */
|
||||||
|
string finalOutput;
|
||||||
|
|
||||||
|
|
||||||
/* Get the GoggaContext */
|
/* Get the GoggaContext */
|
||||||
GoggaContext gCtx = cast(GoggaContext)ctx;
|
GoggaContext gCtx = cast(GoggaContext)ctx;
|
||||||
|
|
||||||
|
@ -16,13 +28,41 @@ public class GoggaTransform : MessageTransform
|
||||||
CompilationInfo compInfo = gCtx.getLineInfo();
|
CompilationInfo compInfo = gCtx.getLineInfo();
|
||||||
string[] context = compInfo.toArray();
|
string[] context = compInfo.toArray();
|
||||||
|
|
||||||
/* Module information (and status debugColoring) */
|
/* Extract the Level */
|
||||||
string moduleInfo = cast(string)debugColor("["~context[1]~"]", gCtx.getLevel());
|
Level level = gCtx.getLevel();
|
||||||
|
|
||||||
/* Function and line number info */
|
|
||||||
string funcInfo = cast(string)(colorSrc("("~context[4]~":"~context[2]~")"));
|
|
||||||
|
|
||||||
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