-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
39 lines (32 loc) · 927 Bytes
/
logger.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
package log
import (
stdlog "log"
"os"
)
type Logger interface {
Printf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
}
// stdLogger implements the logger interface using the log package.
// There is no need to specify a date/time prefix since stdout and stderr
// are logged in StackDriver with those values already present.
type stdLogger struct {
stderr *stdlog.Logger
stdout *stdlog.Logger
}
func NewStdLogger() *stdLogger {
return &stdLogger{
stdout: stdlog.New(os.Stdout, "", 0),
stderr: stdlog.New(os.Stderr, "", 0),
}
}
func (l *stdLogger) Printf(format string, args ...interface{}) {
l.stdout.Printf(format, args...)
}
func (l *stdLogger) Errorf(format string, args ...interface{}) {
l.stderr.Printf(format, args...)
}
func (l *stdLogger) Fatalf(format string, args ...interface{}) {
l.stderr.Fatalf(format, args...)
}