summaryrefslogtreecommitdiff
path: root/libgo/go/syslog/syslog_solaris.go
blob: 044351dbfd44c654bda0cedf0915610ad1617f07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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"
	"os"
	"syscall"
)

func unixSyslog() (conn serverConn, err os.Error) {
	return libcConn(0), nil
}

type libcConn int

func syslog_c(int, *byte)

func (libcConn) writeBytes(p Priority, prefix string, b []byte) (int, os.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, os.Error) {
	syslog_c(int(p), syscall.StringBytePtr(fmt.Sprintf("%s: %s", prefix, s)))
	return len(s), nil
}

func (libcConn) close() os.Error {
	return nil
}