-
Notifications
You must be signed in to change notification settings - Fork 2
/
gol.go
44 lines (39 loc) · 868 Bytes
/
gol.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
/*
Package gol provides a simple logging framework, inspired by SLF4J.
*/
package gol
import (
"fmt"
"os"
"runtime"
)
var (
// defaultFactory is the default logger factory that is used by GetLogger().
defaultFactory = NewFactory(os.Stdout)
// debugMode allows Print to write results to standard error.
debugMode = false
)
// GetLogger returns Logger in the default logger factory.
func GetLogger(name string) Logger {
return defaultFactory.GetLogger(name)
}
// SetDebugMode sets debug mode in gol package.
func SetDebugMode(val bool) {
debugMode = val
}
// Print prints to standard error, used for debugging.
func Print(args ...interface{}) {
if !debugMode {
return
}
var (
file string
line int
ok bool
)
_, file, line, ok = runtime.Caller(1)
if ok {
fmt.Fprintf(os.Stderr, "%s:%d: ", file, line)
}
fmt.Fprintln(os.Stderr, args...)
}