libgocryptfs/internal/tlog/log_go1.5.go
Jakob Unterwurzacher c400aca5cf tlog: clean up messages from the go-fuse library
Drop the date and add the "go-fuse: " prefix so you can see
where the message is coming from.

Before:
  Jun 27 09:03:15 brikett gocryptfs[4150]: 2016/06/27 09:03:15 Unimplemented opcode INTERRUPT
After:
  Jun 27 09:10:58 brikett gocryptfs[4961]: go-fuse: Unimplemented opcode INTERRUPT
2016-06-27 09:12:03 +02:00

33 lines
668 B
Go

// +build go1.5
// = go 1.5 or higher
package tlog
import (
"log"
"log/syslog"
)
func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
w, err := syslog.New(p, ProgramName)
if err != nil {
Warn.Printf("SwitchToSyslog: %v", err)
} else {
l.SetOutput(w)
}
}
// 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 {
log.SetPrefix("go-fuse: ")
// Disable printing the timestamp, syslog already provides that
log.SetFlags(0)
log.SetOutput(w)
}
}