syslog: split Unix domain support from network support.

This is to make it easier to support Solaris syslog.  On
Solaris syslog messages are sent via STREAMS using putmsg to
/dev/conslog.  The putmsg call uses a a control buffer of type
log_cdtl and a data buffer which is the message, and it is in
general a big mess.  This CL just splits out the Unix domain
support so that Solaris can use a different mechanism.  I do
not propose to implement the Solaris support today.  This
split will make it possible for gccgo to just call the libc
function for now.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4261061
This commit is contained in:
Ian Lance Taylor 2011-03-09 13:15:46 -08:00
parent ec5c475919
commit 8206cce117
3 changed files with 62 additions and 24 deletions

View file

@ -0,0 +1,31 @@
// Copyright 2009 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.
package syslog
import (
"net"
"os"
)
// unixSyslog opens a connection to the syslog daemon running on the
// local machine using a Unix domain socket.
func unixSyslog() (conn serverConn, err os.Error) {
logTypes := []string{"unixgram", "unix"}
logPaths := []string{"/dev/log", "/var/run/syslog"}
var raddr string
for _, network := range logTypes {
for _, path := range logPaths {
raddr = path
conn, err := net.Dial(network, "", raddr)
if err != nil {
continue
} else {
return netConn{conn}, nil
}
}
}
return nil, os.ErrorString("Unix syslog delivery error")
}