-
Notifications
You must be signed in to change notification settings - Fork 19
/
impl.go
35 lines (31 loc) · 855 Bytes
/
impl.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
package cmdlogger
import (
"flag"
"log"
"github.com/Symantec/Dominator/lib/log/debuglogger"
)
func init() {
flag.BoolVar(&stdOptions.Datestamps, "logDatestamps", false,
"If true, prefix logs with datestamps")
flag.IntVar(&stdOptions.DebugLevel, "logDebugLevel", -1, "Debug log level")
flag.BoolVar(&stdOptions.Subseconds, "logSubseconds", false,
"If true, datestamps will have subsecond resolution")
}
func newLogger(options Options) *debuglogger.Logger {
if options.DebugLevel < -1 {
options.DebugLevel = -1
}
if options.DebugLevel > 65535 {
options.DebugLevel = 65535
}
logFlags := 0
if options.Datestamps {
logFlags |= log.LstdFlags
if options.Subseconds {
logFlags |= log.Lmicroseconds
}
}
logger := debuglogger.New(log.New(options.Writer, "", logFlags))
logger.SetLevel(int16(options.DebugLevel))
return logger
}