-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger_unix.go
47 lines (37 loc) · 1.15 KB
/
logger_unix.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
// +build !windows
package auth
import (
"fmt"
"log/syslog"
)
type SysLogger struct {
*syslog.Writer
}
func NewSysLogger(tag string) (*SysLogger, error) {
w, err := syslog.New(syslog.LOG_INFO, tag)
if err != nil {
return nil, err
}
return &SysLogger{w}, nil
}
// Debugf formats its arguments according to the format, analogous to fmt.Printf,
// and records the text as a log message at Debug level.
func (l *SysLogger) Debugf(format string, args ...interface{}) {
l.Writer.Debug(fmt.Sprintf(format, args...))
}
// Infof is like Debugf, but at Info level.
func (l *SysLogger) Infof(format string, args ...interface{}) {
l.Writer.Info(fmt.Sprintf(format, args...))
}
// Warningf is like Debugf, but at Warning level.
func (l *SysLogger) Warningf(format string, args ...interface{}) {
l.Writer.Warning(fmt.Sprintf(format, args...))
}
// Errorf is like Debugf, but at Error level.
func (l *SysLogger) Errorf(format string, args ...interface{}) {
l.Writer.Err(fmt.Sprintf(format, args...))
}
// Criticalf is like Debugf, but at Critical level.
func (l *SysLogger) Criticalf(format string, args ...interface{}) {
l.Writer.Crit(fmt.Sprintf(format, args...))
}