-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
53 lines (44 loc) · 978 Bytes
/
debug.go
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
package gowindow
import "fmt"
var dbg = Debugger{
isRunning: true,
isLogging: true,
isProfiling: true,
}
// Debugger general purpose logging and profiling
type Debugger struct {
isRunning bool
isLogging bool
isProfiling bool
}
// Init set debugger runnng on start up
func (d Debugger) Init() Debugger {
d.Log("debug.go", "Debugger.Init()")
d.isRunning = true
d.isLogging = true
d.isProfiling = true
return d
}
// Log prints to terminal
func (d *Debugger) Log(i ...interface{}) {
if d.Logging() {
fmt.Print("[LOG] ")
fmt.Println(i...)
}
}
// Running checks if debugger is on
func (d *Debugger) Running() bool {
return d.isRunning
}
// Logging checks if logging is on
func (d *Debugger) Logging() bool {
return d.isRunning && d.isLogging
}
// Profiling checks if profiling is on
func (d *Debugger) Profiling() bool {
return d.isRunning && d.isProfiling
}
// // SetDebug turn debugging mode on or off
// func SetDebug() {
// debug = true
// }