diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-12-19 12:34:30 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-12-19 12:34:30 -0500 |
commit | 4a3a5525172afd69bc674a2a344065cd9e9a5888 (patch) | |
tree | fb61a19077d5eebbba8c82380cbc44fe7dbfdeb0 /sd_daemon/log.go | |
parent | 9709d1ec5dc9e1cd1ef17b8cc4f5257cae6bf31c (diff) |
Whoops, methods need to be on *Logger, not Logger
Diffstat (limited to 'sd_daemon/log.go')
-rw-r--r-- | sd_daemon/log.go | 15 |
1 files changed, 8 insertions, 7 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} } |