1 module utils.logger;
2 
3 
4 import
5 		std.conv,
6 		std.range,
7 		std..string,
8 		std.algorithm,
9 
10 		core.stdc.stdio,
11 
12 		utils.console;
13 
14 
15 struct Logger
16 {
17 	void info(A...)(A args)
18 	{
19 		log(CC_FG_GREEN, args);
20 	}
21 
22 	void info2(A...)(A args)
23 	{
24 		log(CC_FG_MAGENTA, args);
25 	}
26 
27 	void info3(A...)(A args)
28 	{
29 		log(CC_FG_WHITE, args);
30 	}
31 
32 	void error(A...)(A args)
33 	{
34 		log(CC_FG_RED, args);
35 	}
36 
37 	void warning(A...)(A args)
38 	{
39 		log(CC_FG_YELLOW, args);
40 	}
41 
42 	void opCall(A...)(A args)
43 	{
44 		log(CC_FG_CYAN, args);
45 	}
46 
47 	ubyte ident;
48 private:
49 	void log(A...)(int c, A args)
50 	{
51 		static if(args.length == 1)
52 		{
53 			ident.iota.each!(a => write(c, "\t"));
54 			write(c, args[0].to!string);
55 			write(c, "\n");
56 		}
57 		else
58 		{
59 			log(c, format(args));
60 		}
61 	}
62 
63 	void write(int color, string s)
64 	{
65 		cc_fprintf(color, stdout, "%.*s", s.length, s.ptr);
66 	}
67 }
68 
69 __gshared Logger logger;
70 
71 unittest
72 {
73 	logger(`hello, world`);
74 }