forked from skull-squadron/bloomfilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.go
37 lines (32 loc) · 756 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
// Package bloomfilter is face-meltingly fast, thread-safe,
// marshalable, unionable, probability- and
// optimal-size-calculating Bloom filter in go
//
// https://github.com/steakknife/bloomfilter
//
// Copyright © 2014, 2015, 2018 Barry Allard
//
// MIT license
//
package bloomfilter
import (
"log"
"os"
)
const debugVar = "GOLANG_STEAKKNIFE_BLOOMFILTER_DEBUG"
// EnableDebugging permits debug() logging of details to stderr
func EnableDebugging() {
err := os.Setenv(debugVar, "1")
if err != nil {
panic("Unable to Setenv " + debugVar)
}
}
func debugging() bool {
return os.Getenv(debugVar) != ""
}
// debug printing when debugging() is true
func debug(format string, a ...interface{}) {
if debugging() {
log.Printf(format, a...)
}
}