-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.go
53 lines (44 loc) · 1.18 KB
/
defaults.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 log
import (
"os"
"text/template"
)
// Default logger namespace
var defaultNamespace = "main"
// Current logging level
// can be changed by SetLevel()
// is inherited by NamedLogger
// but can be overwritten
var loggingLevel = INFO
// Default log format
// can be changed by SetFormat()
// is inherited by NamedLogger
// but can be overwritten
// is actually text/template format
var defaultFormat = "[{{.Timestamp}}] {{.Namespace}} {{.Level}}: {{.Message}}"
// Default time format
// can be changed by SetTimeFormat()
// is inherited by NamedLogger
// but can be overwritten
// is actually golang builtin time formatter
// (which is horrible by the way)
var defaultTimeFormat = "2006-01-02 15:04:05 -0700"
// Default output where the logs will be written
// can be changed by SetHandler()
// is inherited by NamedLogger
// but can be overwritten
// uses io.Writer as type
var output = &out{output: os.Stderr}
var defaultLogger *logger
func init() {
format, err := template.New(defaultNamespace).Parse(defaultFormat)
if err != nil {
panic(err)
}
defaultLogger = &logger{
namespace: &defaultNamespace,
format: format,
timeFormat: &defaultTimeFormat,
output: output,
}
}