Retro68/gcc/libgo/go/log/syslog/syslog_libc.go

42 lines
943 B
Go
Raw Normal View History

2012-03-27 23:13:14 +00:00
// Copyright 2011 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.
// gccgo specific implementation of syslog for Solaris. Solaris uses
// STREAMS to communicate with syslogd. That is enough of a pain that
// we just call the libc function.
package syslog
import (
"fmt"
2014-09-21 17:33:12 +00:00
"os"
2012-03-27 23:13:14 +00:00
"syscall"
2014-09-21 17:33:12 +00:00
"time"
2012-03-27 23:13:14 +00:00
)
func unixSyslog() (conn serverConn, err error) {
return libcConn(0), nil
}
type libcConn int
func syslog_c(int, *byte)
2014-09-21 17:33:12 +00:00
func (libcConn) writeString(p Priority, hostname, tag, msg, nl string) error {
timestamp := time.Now().Format(time.RFC3339)
log := fmt.Sprintf("%s %s %s[%d]: %s%s", timestamp, hostname, tag, os.Getpid(), msg, nl)
buf, err := syscall.BytePtrFromString(log)
if err != nil {
return err
}
syscall.Entersyscall()
syslog_c(int(p), buf)
syscall.Exitsyscall()
return nil
2012-03-27 23:13:14 +00:00
}
func (libcConn) close() error {
return nil
}