diff options
author | Jakob Unterwurzacher | 2016-01-22 21:39:35 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-01-22 21:41:34 +0100 |
commit | df41183e9b86ffd152203f4addfb649319b2cb6e (patch) | |
tree | 44ddbd30eaccad593dd6bece188d2d2f7de71cd9 | |
parent | 505fef5a3c514b1cfaa545ebeaa49127a6ec862e (diff) |
Disable syslog in Go 1.4 and lower (method SetOutput does not exist)
-rw-r--r-- | cryptfs/log.go | 9 | ||||
-rw-r--r-- | cryptfs/log_go1.4.go | 8 | ||||
-rw-r--r-- | cryptfs/log_go1.5.go | 17 |
3 files changed, 25 insertions, 9 deletions
diff --git a/cryptfs/log.go b/cryptfs/log.go index a5b5115..44cb84f 100644 --- a/cryptfs/log.go +++ b/cryptfs/log.go @@ -3,7 +3,6 @@ package cryptfs import ( "encoding/json" "log" - "log/syslog" "os" ) @@ -34,14 +33,6 @@ func (l *toggledLogger) Println(v ...interface{}) { } 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 // Debug messages diff --git a/cryptfs/log_go1.4.go b/cryptfs/log_go1.4.go new file mode 100644 index 0000000..6bc6457 --- /dev/null +++ b/cryptfs/log_go1.4.go @@ -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") +} diff --git a/cryptfs/log_go1.5.go b/cryptfs/log_go1.5.go new file mode 100644 index 0000000..8daae9c --- /dev/null +++ b/cryptfs/log_go1.5.go @@ -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) + } +} |