-
Notifications
You must be signed in to change notification settings - Fork 19
/
api.go
39 lines (32 loc) · 1.23 KB
/
api.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
package hopwatch
import "log"
// Printf formats according to a format specifier and writes to the debugger screen.
// It returns a new Watchpoint to send more or break.
func Printf(format string, params ...interface{}) *Watchpoint {
wp := &Watchpoint{offset: 2}
return wp.Printf(format, params...)
}
// Display sends variable name,value pairs to the debugger.
// The parameter nameValuePairs must be even sized.
func Display(nameValuePairs ...interface{}) *Watchpoint {
wp := &Watchpoint{offset: 2}
return wp.Display(nameValuePairs...)
}
// Break suspends the execution of the program and waits for an instruction from the debugger (e.g. Resume).
// Break is only effective if all (if any) conditions are true. The program will resume otherwise.
func Break(conditions ...bool) {
suspend(2, conditions...)
}
// CallerOffset (default=2) allows you to change the file indicator in hopwatch.
// Use this method when you wrap the .CallerOffset(..).Display(..).Break() in your own function.
func CallerOffset(offset int) *Watchpoint {
return (&Watchpoint{}).CallerOffset(offset)
}
func Disable() {
log.Print("[hopwatch] disabled by code.\n")
hopwatchEnabled = false
}
func Enable() {
log.Print("[hopwatch] enabled by code.\n")
hopwatchEnabled = true
}