PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / go / log / syslog / syslog_libc.go
blob48963b4350b42382ea375880e8d6aa416f61c4fa
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build solaris irix
7 // gccgo specific implementation of syslog for Solaris. Solaris uses
8 // STREAMS to communicate with syslogd. That is enough of a pain that
9 // we just call the libc function.
11 package syslog
13 import (
14 "fmt"
15 "os"
16 "syscall"
17 "time"
20 func unixSyslog() (conn serverConn, err error) {
21 return libcConn(0), nil
24 type libcConn int
26 func syslog_c(int, *byte)
28 func (libcConn) writeString(p Priority, hostname, tag, msg, nl string) error {
29 timestamp := time.Now().Format(time.RFC3339)
30 log := fmt.Sprintf("%s %s %s[%d]: %s%s", timestamp, hostname, tag, os.Getpid(), msg, nl)
31 buf, err := syscall.BytePtrFromString(log)
32 if err != nil {
33 return err
35 syscall.Entersyscall()
36 syslog_c(int(p), buf)
37 syscall.Exitsyscall()
38 return nil
41 func (libcConn) close() error {
42 return nil