1 module utils.logger; 2 3 4 import 5 std.stdio, 6 std.range, 7 std.string, 8 9 arsd.terminal; 10 11 12 struct Logger 13 { 14 void info(A...)(A args) 15 { 16 log(Color.green | Bright, args); 17 } 18 19 void info2(A...)(A args) 20 { 21 log(Color.magenta | Bright, args); 22 } 23 24 void info3(A...)(A args) 25 { 26 log(Color.white, args); 27 } 28 29 void error(A...)(A args) 30 { 31 log(Color.red | Bright, args); 32 } 33 34 void warning(A...)(A args) 35 { 36 log(Color.yellow | Bright, args); 37 } 38 39 void opCall(A...)(A args) 40 { 41 log(Color.cyan | Bright, args); 42 } 43 44 ubyte ident; 45 private: 46 void log(A...)(int c, A args) 47 { 48 static if(args.length == 1) 49 { 50 auto term = Terminal(ConsoleOutputType.minimalProcessing); 51 term.color(c, Color.DEFAULT); 52 53 "\t".repeat(ident).join.write; 54 args[0].writeln; 55 } 56 else 57 { 58 log(c, format(args)); 59 } 60 } 61 } 62 63 __gshared Logger logger;