From 7ad503825fb0911c0075b6773c2aa0845cc28365 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 2 Mar 2023 13:44:10 +0200 Subject: [PATCH] - Adding transform modes --- source/gogga/transform.d | 54 ++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/source/gogga/transform.d b/source/gogga/transform.d index 0543173..6fea20d 100644 --- a/source/gogga/transform.d +++ b/source/gogga/transform.d @@ -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 [] (/:) + + /** + * Simple mode is just: `[] ` + */ + if(mode == GoggaMode.SIMPLE) + { + finalOutput = cast(string)debugColor("["~to!(string)(level)~"] "~text); + } + /** + * TwoKTwenty3 is: `[] (:) ` + */ + 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; } }