github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/third_party/gofrontend/libgo/go/log/syslog/syslog_libc.go (about) 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. 4 5 // gccgo specific implementation of syslog for Solaris. Solaris uses 6 // STREAMS to communicate with syslogd. That is enough of a pain that 7 // we just call the libc function. 8 9 package syslog 10 11 import ( 12 "fmt" 13 "os" 14 "syscall" 15 "time" 16 ) 17 18 func unixSyslog() (conn serverConn, err error) { 19 return libcConn(0), nil 20 } 21 22 type libcConn int 23 24 func syslog_c(int, *byte) 25 26 func (libcConn) writeString(p Priority, hostname, tag, msg, nl string) error { 27 timestamp := time.Now().Format(time.RFC3339) 28 log := fmt.Sprintf("%s %s %s[%d]: %s%s", timestamp, hostname, tag, os.Getpid(), msg, nl) 29 buf, err := syscall.BytePtrFromString(log) 30 if err != nil { 31 return err 32 } 33 syscall.Entersyscall() 34 syslog_c(int(p), buf) 35 syscall.Exitsyscall() 36 return nil 37 } 38 39 func (libcConn) close() error { 40 return nil 41 }