1 module gogga;
2 
3 import std.conv : to;
4 import std.stdio : write, stdout;
5 
6 public enum DebugType
7 {
8     INFO,
9     WARNING,
10     ERROR
11 }
12 
13 byte[] generateMessage(string message, DebugType debugType)
14 {
15     /* The generated message */
16     byte[] messageBytes;
17 
18     /* If INFO, set green */
19     if(debugType == DebugType.INFO)
20     {
21         messageBytes = cast(byte[])[27, '[','3','2','m'];
22     }
23     /* If WARNING, set warning */
24     else if(debugType == DebugType.WARNING)
25     {
26         messageBytes = cast(byte[])[27, '[','3','5','m']; /* TODO: FInd yllow */
27     }
28     /* If ERROR, set error */
29     else if(debugType == DebugType.ERROR)
30     {
31         messageBytes = cast(byte[])[27, '[','3','1','m'];
32     }
33 
34     /* Write the message type */
35     messageBytes ~= "["~to!(string)(debugType)~"] ";
36 
37     /* Switch back color */
38     messageBytes ~= cast(byte[])[27, '[', '3', '9', 'm'];
39 
40     /* Append message */
41     messageBytes ~= message;
42 
43     return messageBytes;
44 }
45 
46 void gprint(messageT)(messageT message, DebugType debugType = DebugType.INFO)
47 {
48     /* Generate the message */
49     byte[] messageBytes = generateMessage(message, debugType);
50 
51     /* Print the message */
52     write(cast(string)messageBytes);
53 }
54 
55 void gprintln(messageT)(messageT message, DebugType debugType = DebugType.INFO)
56 {
57     /* Generate the string to print */
58     string printStr = to!(string)(message)~"\n";
59 
60     /* Call `gprint` */
61     gprint(printStr, debugType);
62 }