summaryrefslogtreecommitdiff
path: root/sd_daemon/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'sd_daemon/log.go')
-rw-r--r--sd_daemon/log.go15
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}
}