diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-12-17 21:07:27 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-12-17 21:07:27 +0000 |
commit | 07f9e7b11c109adc3d257bf178e38191833a9ffd (patch) | |
tree | 7569f819ecc7d1b7b0ed44db9354f6d9e0a34444 /libgo | |
parent | f71d567810f721c77585a3eb9ac5b629f5d7f5a5 (diff) | |
download | gcc-07f9e7b11c109adc3d257bf178e38191833a9ffd.tar.gz |
log/syslog: Solaris portability patches.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194566 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/log/syslog/syslog_libc.go | 21 |
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 fb98ad78060..2d14d5d20a8 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 { |