summaryrefslogtreecommitdiff
path: root/libgo/go/log/syslog
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/log/syslog')
-rw-r--r--libgo/go/log/syslog/syslog.go28
-rw-r--r--libgo/go/log/syslog/syslog_test.go7
-rw-r--r--libgo/go/log/syslog/syslog_unix.go2
3 files changed, 26 insertions, 11 deletions
diff --git a/libgo/go/log/syslog/syslog.go b/libgo/go/log/syslog/syslog.go
index aef63480f16..f53310cb0a1 100644
--- a/libgo/go/log/syslog/syslog.go
+++ b/libgo/go/log/syslog/syslog.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build !windows,!plan9
+
// Package syslog provides a simple interface to the system log service. It
// can send messages to the syslog daemon using UNIX domain sockets, UDP, or
// TCP connections.
@@ -136,25 +138,33 @@ func (w *Writer) Debug(m string) (err error) {
}
func (n netConn) writeBytes(p Priority, prefix string, b []byte) (int, error) {
- return fmt.Fprintf(n.conn, "<%d>%s: %s\n", p, prefix, b)
+ _, err := fmt.Fprintf(n.conn, "<%d>%s: %s\n", p, prefix, b)
+ if err != nil {
+ return 0, err
+ }
+ return len(b), nil
}
func (n netConn) writeString(p Priority, prefix string, s string) (int, error) {
- return fmt.Fprintf(n.conn, "<%d>%s: %s\n", p, prefix, s)
+ _, err := fmt.Fprintf(n.conn, "<%d>%s: %s\n", p, prefix, s)
+ if err != nil {
+ return 0, err
+ }
+ return len(s), nil
}
func (n netConn) close() error {
return n.conn.Close()
}
-// NewLogger provides an object that implements the full log.Logger interface,
-// but sends messages to Syslog instead; flag is passed as is to Logger;
-// priority will be used for all messages sent using this interface.
-// All messages are logged with priority p.
-func NewLogger(p Priority, flag int) *log.Logger {
+// NewLogger creates a log.Logger whose output is written to
+// the system log service with the specified priority. The logFlag
+// argument is the flag set passed through to log.New to create
+// the Logger.
+func NewLogger(p Priority, logFlag int) (*log.Logger, error) {
s, err := New(p, "")
if err != nil {
- return nil
+ return nil, err
}
- return log.New(s, "", flag)
+ return log.New(s, "", logFlag), nil
}
diff --git a/libgo/go/log/syslog/syslog_test.go b/libgo/go/log/syslog/syslog_test.go
index b9793e91abd..0fd6239059a 100644
--- a/libgo/go/log/syslog/syslog_test.go
+++ b/libgo/go/log/syslog/syslog_test.go
@@ -1,6 +1,9 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+
+// +build !windows,!plan9
+
package syslog
import (
@@ -61,9 +64,9 @@ func TestNewLogger(t *testing.T) {
if skipNetTest(t) {
return
}
- f := NewLogger(LOG_INFO, 0)
+ f, err := NewLogger(LOG_INFO, 0)
if f == nil {
- t.Error("NewLogger() failed")
+ t.Error(err)
}
}
diff --git a/libgo/go/log/syslog/syslog_unix.go b/libgo/go/log/syslog/syslog_unix.go
index b1c929ad2fe..46a164dd577 100644
--- a/libgo/go/log/syslog/syslog_unix.go
+++ b/libgo/go/log/syslog/syslog_unix.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build !windows,!plan9
+
package syslog
import (