2016-01-22 21:39:35 +01:00
|
|
|
// +build go1.5
|
|
|
|
// = go 1.5 or higher
|
|
|
|
|
2016-06-15 23:30:44 +02:00
|
|
|
package tlog
|
2016-01-22 21:39:35 +01:00
|
|
|
|
|
|
|
import (
|
2016-06-26 23:30:22 +02:00
|
|
|
"log"
|
2016-01-22 21:39:35 +01:00
|
|
|
"log/syslog"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
|
2016-02-06 19:20:54 +01:00
|
|
|
w, err := syslog.New(p, ProgramName)
|
2016-01-22 21:39:35 +01:00
|
|
|
if err != nil {
|
2016-06-26 23:30:22 +02:00
|
|
|
Warn.Printf("SwitchToSyslog: %v", err)
|
2016-01-22 21:39:35 +01:00
|
|
|
} else {
|
|
|
|
l.SetOutput(w)
|
|
|
|
}
|
|
|
|
}
|
2016-06-26 23:30:22 +02:00
|
|
|
|
|
|
|
// SwitchLoggerToSyslog redirects the default log.Logger that the go-fuse lib uses
|
|
|
|
// to syslog.
|
|
|
|
func SwitchLoggerToSyslog(p syslog.Priority) {
|
|
|
|
w, err := syslog.New(p, ProgramName)
|
|
|
|
if err != nil {
|
|
|
|
Warn.Printf("SwitchLoggerToSyslog: %v", err)
|
|
|
|
} else {
|
2016-06-27 09:12:03 +02:00
|
|
|
log.SetPrefix("go-fuse: ")
|
|
|
|
// Disable printing the timestamp, syslog already provides that
|
|
|
|
log.SetFlags(0)
|
2016-06-26 23:30:22 +02:00
|
|
|
log.SetOutput(w)
|
|
|
|
}
|
|
|
|
}
|