/usr/share/gocode/src/github.com/hlandau/xlog/syslogsink.go is in golang-github-hlandau-xlog-dev 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | package xlog
import "fmt"
// Interface compatible with "log/syslog".Writer.
type Syslogger interface {
Alert(m string) error
Crit(m string) error
Debug(m string) error
Emerg(m string) error
Err(m string) error
Info(m string) error
Notice(m string) error
Warning(m string) error
}
// A sink that logs to a "log/syslog".Writer-like interface.
type SyslogSink struct {
s Syslogger
minSeverity Severity
}
// Create a new syslog sink. "log/syslog".Writer implements Syslogger.
func NewSyslogSink(syslogger Syslogger) *SyslogSink {
return &SyslogSink{
s: syslogger,
minSeverity: SevDebug,
}
}
func (ss *SyslogSink) SetSeverity(sev Severity) {
ss.minSeverity = sev
}
func (ss *SyslogSink) ReceiveLocally(sev Severity, format string, params ...interface{}) {
ss.ReceiveFromChild(sev, format, params...)
}
func (ss *SyslogSink) ReceiveFromChild(sev Severity, format string, params ...interface{}) {
if sev > ss.minSeverity {
return
}
s := fmt.Sprintf(format, params...)
switch sev {
case SevEmergency:
ss.s.Emerg(s)
case SevAlert:
ss.s.Alert(s)
case SevCritical:
ss.s.Crit(s)
case SevError:
ss.s.Err(s)
case SevWarn:
ss.s.Warning(s)
case SevNotice:
ss.s.Notice(s)
case SevInfo:
ss.s.Info(s)
default:
ss.s.Debug(s)
}
}
|