Disable syslog in Go 1.4 and lower (method SetOutput does not exist)
This commit is contained in:
parent
505fef5a3c
commit
df41183e9b
@ -3,7 +3,6 @@ package cryptfs
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"log/syslog"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,14 +33,6 @@ func (l *toggledLogger) Println(v ...interface{}) {
|
|||||||
}
|
}
|
||||||
l.Logger.Println(v...)
|
l.Logger.Println(v...)
|
||||||
}
|
}
|
||||||
func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
|
|
||||||
w, err := syslog.New(p, PROGRAM_NAME)
|
|
||||||
if err != nil {
|
|
||||||
Warn.Printf("Cannot switch 0x%02x to syslog: %v", p, err)
|
|
||||||
} else {
|
|
||||||
l.SetOutput(w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// As defined by http://elinux.org/Debugging_by_printing#Log_Levels
|
// As defined by http://elinux.org/Debugging_by_printing#Log_Levels
|
||||||
// Debug messages
|
// Debug messages
|
||||||
|
8
cryptfs/log_go1.4.go
Normal file
8
cryptfs/log_go1.4.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// +build !go1.5
|
||||||
|
// = go 1.4 or lower
|
||||||
|
|
||||||
|
package cryptfs
|
||||||
|
|
||||||
|
func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
|
||||||
|
Debug.Printf("Cannot switch to syslog - need Go 1.5 or higher")
|
||||||
|
}
|
17
cryptfs/log_go1.5.go
Normal file
17
cryptfs/log_go1.5.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build go1.5
|
||||||
|
// = go 1.5 or higher
|
||||||
|
|
||||||
|
package cryptfs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log/syslog"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
|
||||||
|
w, err := syslog.New(p, PROGRAM_NAME)
|
||||||
|
if err != nil {
|
||||||
|
Warn.Printf("Cannot switch 0x%02x to syslog: %v", p, err)
|
||||||
|
} else {
|
||||||
|
l.SetOutput(w)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user