mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-28 20:01:18 +08:00
log/syslog: Solaris portability patches.
From-SVN: r194566
This commit is contained in:
parent
a48bd7c6a5
commit
a57bf4070a
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user