aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-12-17 21:07:27 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-12-17 21:07:27 +0000
commita57bf4070aa7f8e11bf4659ae52169fed1585605 (patch)
tree7569f819ecc7d1b7b0ed44db9354f6d9e0a34444
parenta48bd7c6a5991e8007fbd25285ac56f76e2561d7 (diff)
downloadgcc-a57bf4070aa7f8e11bf4659ae52169fed1585605.zip
gcc-a57bf4070aa7f8e11bf4659ae52169fed1585605.tar.gz
gcc-a57bf4070aa7f8e11bf4659ae52169fed1585605.tar.bz2
log/syslog: Solaris portability patches.
From-SVN: r194566
-rw-r--r--libgo/go/log/syslog/syslog_libc.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/libgo/go/log/syslog/syslog_libc.go b/libgo/go/log/syslog/syslog_libc.go
index fb98ad7..2d14d5d 100644
--- a/libgo/go/log/syslog/syslog_libc.go
+++ b/libgo/go/log/syslog/syslog_libc.go
@@ -10,7 +10,9 @@ package syslog
import (
"fmt"
+ "os"
"syscall"
+ "time"
)
func unixSyslog() (conn serverConn, err error) {
@@ -21,14 +23,17 @@ type libcConn int
func syslog_c(int, *byte)
-func (libcConn) writeBytes(p Priority, prefix string, b []byte) (int, error) {
- syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, b)))
- return len(b), nil
-}
-
-func (libcConn) writeString(p Priority, prefix string, s string) (int, error) {
- syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, s)))
- return len(s), nil
+func (libcConn) writeString(p Priority, hostname, tag, msg string) (int, error) {
+ timestamp := time.Now().Format(time.RFC3339)
+ log := fmt.Sprintf("%s %s %s[%d]: %s", timestamp, hostname, tag, os.Getpid(), msg)
+ buf, err := syscall.BytePtrFromString(log)
+ if err != nil {
+ return 0, err
+ }
+ syscall.Entersyscall()
+ syslog_c(int(p), buf)
+ syscall.Exitsyscall()
+ return len(msg), nil
}
func (libcConn) close() error {