Commit a57bf407 by Ian Lance Taylor

log/syslog: Solaris portability patches.

From-SVN: r194566
parent a48bd7c6
...@@ -10,7 +10,9 @@ package syslog ...@@ -10,7 +10,9 @@ package syslog
import ( import (
"fmt" "fmt"
"os"
"syscall" "syscall"
"time"
) )
func unixSyslog() (conn serverConn, err error) { func unixSyslog() (conn serverConn, err error) {
...@@ -21,14 +23,17 @@ type libcConn int ...@@ -21,14 +23,17 @@ type libcConn int
func syslog_c(int, *byte) func syslog_c(int, *byte)
func (libcConn) writeBytes(p Priority, prefix string, b []byte) (int, error) { func (libcConn) writeString(p Priority, hostname, tag, msg string) (int, error) {
syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, b))) timestamp := time.Now().Format(time.RFC3339)
return len(b), nil log := fmt.Sprintf("%s %s %s[%d]: %s", timestamp, hostname, tag, os.Getpid(), msg)
} buf, err := syscall.BytePtrFromString(log)
if err != nil {
func (libcConn) writeString(p Priority, prefix string, s string) (int, error) { return 0, err
syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, s))) }
return len(s), nil syscall.Entersyscall()
syslog_c(int(p), buf)
syscall.Exitsyscall()
return len(msg), nil
} }
func (libcConn) close() error { func (libcConn) close() error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment