From 4a3a5525172afd69bc674a2a344065cd9e9a5888 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 19 Dec 2016 12:34:30 -0500 Subject: Whoops, methods need to be on *Logger, not Logger --- sd_daemon/log.go | 15 ++++++++------- sd_daemon/log_util.go.gen | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sd_daemon/log.go b/sd_daemon/log.go index 806f248..9fa62d4 100644 --- a/sd_daemon/log.go +++ b/sd_daemon/log.go @@ -39,8 +39,9 @@ type Logger struct { buf []byte } -func NewLogger(w io.Writer) Logger { - return Logger{out: w} +// NewLogger creates a new Logger. +func NewLogger(w io.Writer) *Logger { + return &Logger{out: w} } // Log is a Logger that use used very similarly to @@ -49,7 +50,7 @@ func NewLogger(w io.Writer) Logger { // // You are encouraged to use stderr unless you have a good reason to // talk to syslog or journald directly. -var Log = Logger{out: os.Stderr} +var Log = NewLogger(os.Stderr) // Cheap version of // @@ -71,7 +72,7 @@ func appendPrefix(buf []byte, n syslog.Priority) []byte { // WriteString writes a message with the specified priority to the // log. -func (l Logger) WriteString(level syslog.Priority, msg string) (n int, err error) { +func (l *Logger) WriteString(level syslog.Priority, msg string) (n int, err error) { l.mu.Lock() defer l.mu.Unlock() @@ -108,7 +109,7 @@ func (l Logger) WriteString(level syslog.Priority, msg string) (n int, err error // WriteString writes a message with the specified priority to the // log. -func (l Logger) WriteBytes(level syslog.Priority, msg []byte) (n int, err error) { +func (l *Logger) WriteBytes(level syslog.Priority, msg []byte) (n int, err error) { // Copy/pasted from WriteString and // * `strings.` -> `bytes.` // * `"\n"` -> `[]byte{'\n'}` @@ -141,7 +142,7 @@ func (l Logger) WriteBytes(level syslog.Priority, msg []byte) (n int, err error) } type loggerWriter struct { - log Logger + log *Logger level syslog.Priority } @@ -151,6 +152,6 @@ func (lw loggerWriter) Write(p []byte) (n int, err error) { // Writer returns an io.Writer that writes messages with the specified // priority to the log. -func (l Logger) Writer(level syslog.Priority) io.Writer { +func (l *Logger) Writer(level syslog.Priority) io.Writer { return loggerWriter{log: l, level: level} } diff --git a/sd_daemon/log_util.go.gen b/sd_daemon/log_util.go.gen index f7f43c0..95d56b0 100755 --- a/sd_daemon/log_util.go.gen +++ b/sd_daemon/log_util.go.gen @@ -27,7 +27,7 @@ EOF for level in Emerg Alert Crit Err Warning Notice Info Debug; do cat <