Gogga (legacy)

- Disabled
This commit is contained in:
Tristan B. Velloza Kildaire 2024-04-09 14:35:57 +02:00
parent 7baa5dbaef
commit 5c99f3f3b4
1 changed files with 293 additions and 299 deletions

View File

@ -7,361 +7,355 @@ import dlog;
import dlog.utilities : flatten; import dlog.utilities : flatten;
import std.array : join; import std.array : join;
import gogga.transform; // import gogga.transform;
import gogga.context; // import gogga.context;
/**
* The logging class which provides the logging print
* calls, controlling of style and whether to debug or
* not
*/
public class GoggaLogger : Logger
{
/**
* The custom transformer
*/
private GoggaTransform gTransform = new GoggaTransform();
/**
* Whether debug prints are enabled or not
*/
private bool debugEnabled = false;
/**
* Constructs a new GoggaLOgger // /**
*/ // * The logging class which provides the logging print
this() // * calls, controlling of style and whether to debug or
{ // * not
super(gTransform); // */
} // public class GoggaLogger : Logger
// {
// /**
// * The custom transformer
// */
// private GoggaTransform gTransform = new GoggaTransform();
// /**
// * Whether debug prints are enabled or not
// */
// private bool debugEnabled = false;
// /**
// * Constructs a new GoggaLOgger
// */
// this()
// {
// super(gTransform);
// }
/** // /**
* Our underlying logging implementation // * Our underlying logging implementation
* // *
* Params: // * Params:
* text = the text to write // * text = the text to write
*/ // */
public override void logImpl(string text) // public override void logImpl(string text)
{ // {
import std.stdio : write; // import std.stdio : write;
write(text); // write(text);
} // }
/** // /**
* Set the style of print outs // * Set the style of print outs
* // *
* Params: // * Params:
* mode = the GoggaMode wanted // * mode = the GoggaMode wanted
*/ // */
public void mode(GoggaMode mode) // public void mode(GoggaMode mode)
{ // {
gTransform.setMode(mode); // gTransform.setMode(mode);
} // }
/** // /**
* Logs using the default context an arbitrary amount of arguments // * Logs using the default context an arbitrary amount of arguments
* specifically setting the context's level to ERROR // * specifically setting the context's level to ERROR
* // *
* Params: // * Params:
* segments = the arbitrary argumnets (alias sequence) // * segments = the arbitrary argumnets (alias sequence)
* __FILE_FULL_PATH__ = compile time usage file // * __FILE_FULL_PATH__ = compile time usage file
* __FILE__ = compile time usage file (relative) // * __FILE__ = compile time usage file (relative)
* __LINE__ = compile time usage line number // * __LINE__ = compile time usage line number
* __MODULE__ = compile time usage module // * __MODULE__ = compile time usage module
* __FUNCTION__ = compile time usage function // * __FUNCTION__ = compile time usage function
* __PRETTY_FUNCTION__ = compile time usage function (pretty) // * __PRETTY_FUNCTION__ = compile time usage function (pretty)
*/ // */
public void error(TextType...)(TextType segments, // public void error(TextType...)(TextType segments,
string c1 = __FILE_FULL_PATH__, // string c1 = __FILE_FULL_PATH__,
string c2 = __FILE__, ulong c3 = __LINE__, // string c2 = __FILE__, ulong c3 = __LINE__,
string c4 = __MODULE__, string c5 = __FUNCTION__, // string c4 = __MODULE__, string c5 = __FUNCTION__,
string c6 = __PRETTY_FUNCTION__) // string c6 = __PRETTY_FUNCTION__)
{ // {
/* Use the context `GoggaContext` */ // /* Build up the line information */
GoggaContext defaultContext = new GoggaContext(); // GoggaCompInfo compilationInfo = GoggaCompInfo(c1, c2, c3, c4, c5, c6);
/* Build up the line information */ // /**
CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6); // * Grab at compile-time all arguments and generate runtime code to add them to `components`
// */
// string[] components = flatten(segments);
/* Set the line information in the context */ // /* Join all `components` into a single string */
defaultContext.setLineInfo(compilationInfo); // string messageOut = join(components, " ");
/* Set the level to ERROR */ // /* Call the log */
defaultContext.setLevel(Level.ERROR); // logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6);
// }
/** // /**
* Grab at compile-time all arguments and generate runtime code to add them to `components` // * Logs using the default context an arbitrary amount of arguments
*/ // * specifically setting the context's level to INFO
string[] components = flatten(segments); // *
// * Params:
// * segments = the arbitrary argumnets (alias sequence)
// * __FILE_FULL_PATH__ = compile time usage file
// * __FILE__ = compile time usage file (relative)
// * __LINE__ = compile time usage line number
// * __MODULE__ = compile time usage module
// * __FUNCTION__ = compile time usage function
// * __PRETTY_FUNCTION__ = compile time usage function (pretty)
// */
// public void info(TextType...)(TextType segments,
// string c1 = __FILE_FULL_PATH__,
// string c2 = __FILE__, ulong c3 = __LINE__,
// string c4 = __MODULE__, string c5 = __FUNCTION__,
// string c6 = __PRETTY_FUNCTION__)
// {
// /* Use the context `GoggaContext` */
// GoggaContext defaultContext = new GoggaContext();
/* Join all `components` into a single string */ // /* Build up the line information */
string messageOut = join(components, multiArgJoiner); // CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6);
/* Call the log */ // /* Set the line information in the context */
logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6); // defaultContext.setLineInfo(compilationInfo);
}
/** // /* Set the level to INFO */
* Logs using the default context an arbitrary amount of arguments // defaultContext.setLevel(Level.INFO);
* specifically setting the context's level to INFO
*
* Params:
* segments = the arbitrary argumnets (alias sequence)
* __FILE_FULL_PATH__ = compile time usage file
* __FILE__ = compile time usage file (relative)
* __LINE__ = compile time usage line number
* __MODULE__ = compile time usage module
* __FUNCTION__ = compile time usage function
* __PRETTY_FUNCTION__ = compile time usage function (pretty)
*/
public void info(TextType...)(TextType segments,
string c1 = __FILE_FULL_PATH__,
string c2 = __FILE__, ulong c3 = __LINE__,
string c4 = __MODULE__, string c5 = __FUNCTION__,
string c6 = __PRETTY_FUNCTION__)
{
/* Use the context `GoggaContext` */
GoggaContext defaultContext = new GoggaContext();
/* Build up the line information */ // /**
CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6); // * Grab at compile-time all arguments and generate runtime code to add them to `components`
// */
// string[] components = flatten(segments);
/* Set the line information in the context */ // /* Join all `components` into a single string */
defaultContext.setLineInfo(compilationInfo); // string messageOut = join(components, multiArgJoiner);
/* Set the level to INFO */ // /* Call the log */
defaultContext.setLevel(Level.INFO); // logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6);
// }
/** // /**
* Grab at compile-time all arguments and generate runtime code to add them to `components` // * Logs using the default context an arbitrary amount of arguments
*/ // * specifically setting the context's level to WARN
string[] components = flatten(segments); // *
// * Params:
// * segments = the arbitrary argumnets (alias sequence)
// * __FILE_FULL_PATH__ = compile time usage file
// * __FILE__ = compile time usage file (relative)
// * __LINE__ = compile time usage line number
// * __MODULE__ = compile time usage module
// * __FUNCTION__ = compile time usage function
// * __PRETTY_FUNCTION__ = compile time usage function (pretty)
// */
// public void warn(TextType...)(TextType segments,
// string c1 = __FILE_FULL_PATH__,
// string c2 = __FILE__, ulong c3 = __LINE__,
// string c4 = __MODULE__, string c5 = __FUNCTION__,
// string c6 = __PRETTY_FUNCTION__)
// {
// /* Use the context `GoggaContext` */
// GoggaContext defaultContext = new GoggaContext();
/* Join all `components` into a single string */ // /* Build up the line information */
string messageOut = join(components, multiArgJoiner); // CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6);
/* Call the log */ // /* Set the line information in the context */
logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6); // defaultContext.setLineInfo(compilationInfo);
}
/** // /* Set the level to WARN */
* Logs using the default context an arbitrary amount of arguments // defaultContext.setLevel(Level.WARN);
* specifically setting the context's level to WARN
*
* Params:
* segments = the arbitrary argumnets (alias sequence)
* __FILE_FULL_PATH__ = compile time usage file
* __FILE__ = compile time usage file (relative)
* __LINE__ = compile time usage line number
* __MODULE__ = compile time usage module
* __FUNCTION__ = compile time usage function
* __PRETTY_FUNCTION__ = compile time usage function (pretty)
*/
public void warn(TextType...)(TextType segments,
string c1 = __FILE_FULL_PATH__,
string c2 = __FILE__, ulong c3 = __LINE__,
string c4 = __MODULE__, string c5 = __FUNCTION__,
string c6 = __PRETTY_FUNCTION__)
{
/* Use the context `GoggaContext` */
GoggaContext defaultContext = new GoggaContext();
/* Build up the line information */ // /**
CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6); // * Grab at compile-time all arguments and generate runtime code to add them to `components`
// */
// string[] components = flatten(segments);
/* Set the line information in the context */ // /* Join all `components` into a single string */
defaultContext.setLineInfo(compilationInfo); // string messageOut = join(components, multiArgJoiner);
/* Set the level to WARN */ // /* Call the log */
defaultContext.setLevel(Level.WARN); // logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6);
// }
/** // /**
* Grab at compile-time all arguments and generate runtime code to add them to `components` // * Logs using the default context an arbitrary amount of arguments
*/ // * specifically setting the context's level to DEBUG and will
string[] components = flatten(segments); // * only print if debugging is enabled
// *
// * Params:
// * segments = the arbitrary argumnets (alias sequence)
// * __FILE_FULL_PATH__ = compile time usage file
// * __FILE__ = compile time usage file (relative)
// * __LINE__ = compile time usage line number
// * __MODULE__ = compile time usage module
// * __FUNCTION__ = compile time usage function
// * __PRETTY_FUNCTION__ = compile time usage function (pretty)
// */
// public void debug_(TextType...)(TextType segments,
// string c1 = __FILE_FULL_PATH__,
// string c2 = __FILE__, ulong c3 = __LINE__,
// string c4 = __MODULE__, string c5 = __FUNCTION__,
// string c6 = __PRETTY_FUNCTION__)
// {
// /* Only debug if debugging is enabled */
// if(debugEnabled)
// {
// /* Use the context `GoggaContext` */
// GoggaContext defaultContext = new GoggaContext();
/* Join all `components` into a single string */ // /* Build up the line information */
string messageOut = join(components, multiArgJoiner); // CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6);
/* Call the log */ // /* Set the line information in the context */
logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6); // defaultContext.setLineInfo(compilationInfo);
}
/** // /* Set the level to DEBUG */
* Logs using the default context an arbitrary amount of arguments // defaultContext.setLevel(Level.DEBUG);
* specifically setting the context's level to DEBUG and will
* only print if debugging is enabled
*
* Params:
* segments = the arbitrary argumnets (alias sequence)
* __FILE_FULL_PATH__ = compile time usage file
* __FILE__ = compile time usage file (relative)
* __LINE__ = compile time usage line number
* __MODULE__ = compile time usage module
* __FUNCTION__ = compile time usage function
* __PRETTY_FUNCTION__ = compile time usage function (pretty)
*/
public void debug_(TextType...)(TextType segments,
string c1 = __FILE_FULL_PATH__,
string c2 = __FILE__, ulong c3 = __LINE__,
string c4 = __MODULE__, string c5 = __FUNCTION__,
string c6 = __PRETTY_FUNCTION__)
{
/* Only debug if debugging is enabled */
if(debugEnabled)
{
/* Use the context `GoggaContext` */
GoggaContext defaultContext = new GoggaContext();
/* Build up the line information */ // /**
CompilationInfo compilationInfo = CompilationInfo(c1, c2, c3, c4, c5, c6); // * Grab at compile-time all arguments and generate runtime code to add them to `components`
// */
// string[] components = flatten(segments);
/* Set the line information in the context */ // /* Join all `components` into a single string */
defaultContext.setLineInfo(compilationInfo); // string messageOut = join(components, multiArgJoiner);
/* Set the level to DEBUG */ // /* Call the log */
defaultContext.setLevel(Level.DEBUG); // logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6);
// }
// }
/** // /**
* Grab at compile-time all arguments and generate runtime code to add them to `components` // * Alias for debug_
*/ // */
string[] components = flatten(segments); // public alias dbg = debug_;
/* Join all `components` into a single string */ // /**
string messageOut = join(components, multiArgJoiner); // * Enables debug prints
// */
// public void enableDebug()
// {
// this.debugEnabled = true;
// }
/* Call the log */ // /**
logc(defaultContext, messageOut, c1, c2, c3, c4, c5, c6); // * Disables debug prints
} // */
} // public void disableDebug()
// {
// this.debugEnabled = false;
// }
// }
/** // version(unittest)
* Alias for debug_ // {
*/ // import std.stdio : writeln;
public alias dbg = debug_; // }
/** // unittest
* Enables debug prints // {
*/ // GoggaLogger gLogger = new GoggaLogger();
public void enableDebug()
{
this.debugEnabled = true;
}
/** // // Test the normal modes
* Disables debug prints // gLogger.info("This is an info message");
*/ // gLogger.warn("This is a warning message");
public void disableDebug() // gLogger.error("This is an error message");
{
this.debugEnabled = false;
}
}
version(unittest) // // We shouldn't see anything as debug is off
{ // gLogger.dbg("This is a debug which is hidden", 1);
import std.stdio : writeln;
}
unittest // // Now enable debugging and you should see it
{ // gLogger.enableDebug();
GoggaLogger gLogger = new GoggaLogger(); // gLogger.dbg("This is a VISIBLE debug", true);
// Test the normal modes // // Make space between unit tests
gLogger.info("This is an info message"); // writeln();
gLogger.warn("This is a warning message"); // }
gLogger.error("This is an error message");
// We shouldn't see anything as debug is off // unittest
gLogger.dbg("This is a debug which is hidden", 1); // {
// GoggaLogger gLogger = new GoggaLogger();
// gLogger.mode(GoggaMode.TwoKTwenty3);
// Now enable debugging and you should see it // // Test the normal modes
gLogger.enableDebug(); // gLogger.info("This is an info message");
gLogger.dbg("This is a VISIBLE debug", true); // gLogger.warn("This is a warning message");
// gLogger.error("This is an error message");
// Make space between unit tests // // We shouldn't see anything as debug is off
writeln(); // gLogger.dbg("This is a debug which is hidden", 1);
}
unittest // // Now enable debugging and you should see it
{ // gLogger.enableDebug();
GoggaLogger gLogger = new GoggaLogger(); // gLogger.dbg("This is a VISIBLE debug", true);
gLogger.mode(GoggaMode.TwoKTwenty3);
// Test the normal modes // // Make space between unit tests
gLogger.info("This is an info message"); // writeln();
gLogger.warn("This is a warning message"); // }
gLogger.error("This is an error message");
// We shouldn't see anything as debug is off // unittest
gLogger.dbg("This is a debug which is hidden", 1); // {
// GoggaLogger gLogger = new GoggaLogger();
// gLogger.mode(GoggaMode.SIMPLE);
// Now enable debugging and you should see it // // Test the normal modes
gLogger.enableDebug(); // gLogger.info("This is an info message");
gLogger.dbg("This is a VISIBLE debug", true); // gLogger.warn("This is a warning message");
// gLogger.error("This is an error message");
// Make space between unit tests // // We shouldn't see anything as debug is off
writeln(); // gLogger.dbg("This is a debug which is hidden", 1);
}
unittest // // Now enable debugging and you should see it
{ // gLogger.enableDebug();
GoggaLogger gLogger = new GoggaLogger(); // gLogger.dbg("This is a VISIBLE debug", true);
gLogger.mode(GoggaMode.SIMPLE);
// Test the normal modes // // Make space between unit tests
gLogger.info("This is an info message"); // writeln();
gLogger.warn("This is a warning message"); // }
gLogger.error("This is an error message");
// We shouldn't see anything as debug is off // unittest
gLogger.dbg("This is a debug which is hidden", 1); // {
// GoggaLogger gLogger = new GoggaLogger();
// gLogger.mode(GoggaMode.RUSTACEAN);
// Now enable debugging and you should see it // // Test the normal modes
gLogger.enableDebug(); // gLogger.info("This is an info message");
gLogger.dbg("This is a VISIBLE debug", true); // gLogger.warn("This is a warning message");
// gLogger.error("This is an error message");
// Make space between unit tests // // We shouldn't see anything as debug is off
writeln(); // gLogger.dbg("This is a debug which is hidden", 1);
}
unittest // // Now enable debugging and you should see it
{ // gLogger.enableDebug();
GoggaLogger gLogger = new GoggaLogger(); // gLogger.dbg("This is a VISIBLE debug", true);
gLogger.mode(GoggaMode.RUSTACEAN);
// Test the normal modes // // Make space between unit tests
gLogger.info("This is an info message"); // writeln();
gLogger.warn("This is a warning message"); // }
gLogger.error("This is an error message");
// We shouldn't see anything as debug is off // unittest
gLogger.dbg("This is a debug which is hidden", 1); // {
// GoggaLogger gLogger = new GoggaLogger();
// gLogger.mode(GoggaMode.RUSTACEAN_SIMPLE);
// Now enable debugging and you should see it // // Test the normal modes
gLogger.enableDebug(); // gLogger.info("This is an info message");
gLogger.dbg("This is a VISIBLE debug", true); // gLogger.warn("This is a warning message");
// gLogger.error("This is an error message");
// Make space between unit tests // // We shouldn't see anything as debug is off
writeln(); // gLogger.dbg("This is a debug which is hidden", 1);
}
unittest // // Now enable debugging and you should see it
{ // gLogger.enableDebug();
GoggaLogger gLogger = new GoggaLogger(); // gLogger.dbg("This is a VISIBLE debug", true);
gLogger.mode(GoggaMode.RUSTACEAN_SIMPLE);
// Test the normal modes // // Make space between unit tests
gLogger.info("This is an info message"); // writeln();
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();
}