forked from ginuerzh/gost
-
Notifications
You must be signed in to change notification settings - Fork 6
/
log.go
42 lines (34 loc) · 825 Bytes
/
log.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
package gost
import (
"fmt"
"log"
"os"
"strconv"
)
func init() {
if flags, _ := strconv.Atoi(os.Getenv("LOGFLAGS")); flags > 0 {
log.SetFlags(flags)
return
}
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
// LogLogger uses the standard log package as the logger
type LogLogger struct {
}
// Log uses the standard log library log.Output
func (l *LogLogger) Log(v ...interface{}) {
log.Output(3, fmt.Sprintln(v...))
}
// Logf uses the standard log library log.Output
func (l *LogLogger) Logf(format string, v ...interface{}) {
log.Output(3, fmt.Sprintf(format, v...))
}
// NopLogger is a dummy logger that discards the log outputs
type NopLogger struct {
}
// Log does nothing
func (l *NopLogger) Log(v ...interface{}) {
}
// Logf does nothing
func (l *NopLogger) Logf(format string, v ...interface{}) {
}