forked from aler9/dctk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.go
More file actions
37 lines (30 loc) · 667 Bytes
/
log.go
File metadata and controls
37 lines (30 loc) · 667 Bytes
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 dctoolkit
import (
"log"
"os"
)
// set up log once
func init() {
log.SetOutput(os.Stdout)
}
// LogLevel contains the available log levels.
type LogLevel int
const (
// LevelDebug prints everything
LevelDebug LogLevel = iota
// LevelInfo prints only important messages
LevelInfo
// LevelError prints only error messages
LevelError
)
var logLevel = LevelInfo
// SetLogLevel sets the verbosity of the library. See LogLevel for the description
// of the available levels.
func SetLogLevel(level LogLevel) {
logLevel = level
}
func dolog(level LogLevel, text string, args ...interface{}) {
if level >= logLevel {
log.Printf(text, args...)
}
}