summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-12-18 22:40:43 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-12-18 22:40:43 -0500
commit0a43955333992153412a6b8a99b2825c3d0a74ca (patch)
treedeafd73af320d4f067e7ee75eab7d5183a924cc0
parentb0c40f4c505fcf29d3ef8080c5e0d75d49000712 (diff)
sd_daemon/log: implement io.Writer and io.stringWriter where applicable
-rw-r--r--sd_daemon/log.go18
1 files changed, 18 insertions, 0 deletions
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 {