-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.go
More file actions
68 lines (56 loc) · 1.67 KB
/
Copy pathdebug.go
File metadata and controls
68 lines (56 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ansi
var debugMode bool
func init() {
debugMode = false // Use color by default
}
// DisableDebug - Turn on ANSI Debug print functionality. (This is a global setting)
func DisableDebug() *Color {
return (&Color{}).DisableDebug()
}
// DisableDebug - Turn off ANSI Debug print functionality. (This is a global setting)
func (c *Color) DisableDebug() *Color {
debugMode = false
return c
}
// EnableDebug - Turn on ANSI Debug print functionality. (This is a global setting)
func (c *Color) EnableDebug() *Color {
debugMode = true
return c
}
// EnableDebug - Turn on ANSI Debug print functionality. (This is a global setting)
func EnableDebug() *Color {
return (&Color{}).EnableDebug()
}
// Debug - print debug message (if debugging is enabled)
func Debug(msg ...interface{}) *Color {
return (&Color{}).Debug(msg...)
}
// Debugf - print debug message (if debugging is enabled)
func Debugf(format string, msg ...interface{}) *Color {
return (&Color{}).Debugf(format, msg...)
}
// Debugln - print debug message (if debugging is enabled)
func Debugln(msg ...interface{}) *Color {
return (&Color{}).Debugln(msg...)
}
// Debug - print debug message (if debugging is enabled)
func (c *Color) Debug(msg ...interface{}) *Color {
if debugMode {
c.Yellow().Print("[DEBUG]: ")
for _, m := range msg {
c.Print(m.(string))
}
}
return c
}
// Debugf - print debug message (if debugging is enabled)
func (c *Color) Debugf(format string, msg ...interface{}) *Color {
if debugMode {
return Yellow().Printf("[DEBUG]: "+format, msg...)
}
return c
}
// Debugln - print debug message (if debugging is enabled)
func (c *Color) Debugln(msg ...interface{}) *Color {
return c.Debug(msg...).LF()
}