From 0a43955333992153412a6b8a99b2825c3d0a74ca Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 18 Dec 2017 22:40:43 -0500 Subject: sd_daemon/log: implement io.Writer and io.stringWriter where applicable --- sd_daemon/log.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sd_daemon/log.go b/sd_daemon/log.go index 1bdf65f..c8d8419 100644 --- a/sd_daemon/log.go +++ b/sd_daemon/log.go @@ -145,6 +145,20 @@ func (l *Logger) LogBytes(pri syslog.Priority, msg []byte) (n int, err error) { return l.out.Write(l.buf) } +// Write writes a message with priority syslog.LOG_INFO to the log; +// implementing io.Writer. +func (l *Logger) Write(msg []byte) (n int, err error) { + n, err = l.LogBytes(syslog.LOG_INFO, msg) + return n, err +} + +// WriteString writes a message with priority syslog.LOG_INFO to the +// log; implementing io.WriteString's interface. +func (l *Logger) WriteString(msg string) (n int, err error) { + n, err = l.LogString(syslog.LOG_INFO, msg) + return n, err +} + type loggerWriter struct { log *Logger pri syslog.Priority @@ -154,6 +168,10 @@ func (lw loggerWriter) Write(p []byte) (n int, err error) { return lw.log.LogBytes(lw.pri, p) } +func (lw loggerWriter) WriteString(p string) (n int, err error) { + return lw.log.LogString(lw.pri, p) +} + // Writer returns an io.Writer that writes messages with the specified // priority to the log. func (l *Logger) Writer(pri syslog.Priority) io.Writer { -- cgit v1.1-4-g5e80