Creates a new KamelosoLogger with settings divined from the passed CoreSettings struct.
Synonymous alias to KamelosoLogger.all, as a workaround for LogLevel.all not being named LogLevel.log.
Convenience alias.
Synonymous alias to KamelosoLogger.allf, as a workaround for LogLevel.all not being named LogLevel.log.
Synonymous alias to alltint, as a workaround for LogLevel.all not being named LogLevel.log.
Synonymous alias to alltint, as a workaround for LogLevel.all not being named LogLevel.log.
Outputs the header of a logger message.
Outputs the tail of a logger message.
Prints a timestamped log message to screen. Implementation function.
Prints a timestamped log message to screen as per the passed runtime pattern, in printf style. Implementation function.
Prints a timestamped log message to screen as per the passed compile-time pattern, in printf style. Implementation function.
Template for returning tints based on the settings of the this KamelosoLogger.
The initial size to allocate for buffers. It will grow if needed.
Mixin to error out on fatal calls.
Dummy function returning an empty string, since there can be no tints on non-version Colours builds.
Returns the corresponding TerminalForeground for the LogLevel, taking into account whether the terminal is said to be bright or not.
Whether or not to use colours for a bright background.
Whether to use colours or not in logger output.
Whether or not to flush standard out after writing to it.
Whether or not to disable all terminal output.
Buffer to compose a line in before printing it to screen in one go.
Sub-buffer to compose the message in.
1 import kameloso.pods : CoreSettings; 2 3 struct S1 4 { 5 void toString(Sink)(auto ref Sink sink) const 6 { 7 sink.put("sink toString"); 8 } 9 } 10 11 struct S2 12 { 13 void toString(scope void delegate(const(char)[]) dg) const 14 { 15 dg("delegate toString"); 16 } 17 18 @disable this(this); 19 } 20 21 struct S3 22 { 23 string s = "no toString"; 24 } 25 26 struct S4 27 { 28 string toString = "toString literal"; 29 } 30 31 struct S5 32 { 33 string toString()() const 34 { 35 return "template toString"; 36 } 37 } 38 39 class C 40 { 41 override string toString() const 42 { 43 return "plain toString"; 44 } 45 } 46 47 CoreSettings settings; 48 settings.colours = false; 49 settings.brightTerminal = false; 50 settings.headless = false; 51 settings.flush = true; 52 53 auto log_ = new KamelosoLogger(settings); 54 55 log_.logf!"log: %s"("log"); 56 log_.infof!"log: %s"("info"); 57 log_.warningf!"log: %s"("warning"); 58 log_.errorf!"log: %s"("error"); 59 log_.criticalf!"log: %s"("critical"); 60 // log_.fatalf!"log: %s"("FATAL"); 61 log_.tracef!"log: %s"("trace"); 62 log_.offf!"log: %s"("off"); 63 64 version(Colours) 65 { 66 settings.colours = true; 67 settings.brightTerminal = true; 68 log_ = new KamelosoLogger(settings); 69 70 log_.log("log: log"); 71 log_.info("log: info"); 72 log_.warning("log: warning"); 73 log_.error("log: error"); 74 log_.critical("log: critical"); 75 // log_.fatal("log: FATAL"); 76 log_.trace("log: trace"); 77 log_.off("log: off"); 78 79 settings.brightTerminal = false; 80 log_ = new KamelosoLogger(settings); 81 82 log_.log("log: log"); 83 log_.info("log: info"); 84 log_.warning("log: warning"); 85 log_.error("log: error"); 86 // log_.fatal("log: FATAL"); 87 log_.trace("log: trace"); 88 log_.off("log: off"); 89 } 90 91 log_.log("log <i>info</> log <w>warning</> log <e>error</> log <t>trace</> log <o>off</> log"); 92 93 S1 s1; 94 S2 s2; 95 S3 s3; 96 S4 s4; 97 S5 s5; 98 C c = new C; 99 100 log_.trace(); 101 102 log_.log(s1); 103 log_.info(s2); 104 log_.warning(s3); 105 log_.critical(s4); 106 log_.error(s5); 107 log_.trace(c); 108 109 log_.headless = true; 110 log_.error("THIS SHOULD NEVER BE SEEN");
Logger class, used to print timestamped and coloured logging messages.
It is thread-local so instantiate more if you're threading.