1 module nxt.logging;
2 
3 @safe:
4 
5 /++ Log level copied from `std.logger.core.LogLevel`.
6  +/
7 enum LogLevel : ubyte
8 {
9 	all = 1, /** Lowest possible assignable `LogLevel`. */
10 	trace = 32, /** `LogLevel` for tracing the execution of the program. */
11 	info = 64, /** This level is used to display information about the
12 				program. */
13 	warning = 96, /** warnings about the program should be displayed with this
14 				   level. */
15 	error = 128, /** Information about errors should be logged with this
16 				   level.*/
17 	critical = 160, /** Messages that inform about critical errors should be
18 					logged with this level. */
19 	fatal = 192,   /** Log messages that describe fatal errors should use this
20 				  level. */
21 	off = ubyte.max /** Highest possible `LogLevel`. */
22 }
23 
24 enum defaultLogLevel = LogLevel.warning;
25 
26 void trace(Args...)(scope Args args) pure /* nothrow @nogc */ {
27 	import std.stdio : writeln;
28 	/+ TODO: check LogLevel +/
29 	debug writeln("[trace] ", args);
30 }
31 
32 void info(Args...)(scope Args args) pure /* nothrow @nogc */ {
33 	import std.stdio : writeln;
34 	/+ TODO: check LogLevel +/
35 	debug writeln("[info] ", args);
36 }
37 
38 void warning(Args...)(scope Args args) pure /* nothrow @nogc */ {
39 	import std.stdio : writeln;
40 	/+ TODO: check LogLevel +/
41 	debug writeln("[warning] ", args);
42 }
43 
44 void error(Args...)(scope Args args) pure /* nothrow @nogc */ {
45 	import std.stdio : writeln;
46 	/+ TODO: check LogLevel +/
47 	debug writeln("[error] ", args);
48 }
49 
50 void critical(Args...)(scope Args args) pure /* nothrow @nogc */ {
51 	import std.stdio : writeln;
52 	/+ TODO: check LogLevel +/
53 	debug writeln("[critical] ", args);
54 }
55 
56 void fatal(Args...)(scope Args args) pure /* nothrow @nogc */ {
57 	import std.stdio : writeln;
58 	/+ TODO: check LogLevel +/
59 	debug writeln("[fatal] ", args);
60 }