aboutsummaryrefslogtreecommitdiff
path: root/internal/tlog/log_go1.5.go
blob: 40ec656756fb891dc506889ea995fb989683d244 (plain)
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
// +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.SetOutput(w)
	}
}