2011-03-09 23:13:09 +01:00
|
|
|
// 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.
|
|
|
|
|
2012-03-02 21:01:37 +01:00
|
|
|
// +build !windows,!plan9
|
|
|
|
|
2011-03-09 23:13:09 +01:00
|
|
|
package syslog
|
|
|
|
|
|
|
|
import (
|
2011-12-03 03:17:34 +01:00
|
|
|
"errors"
|
2011-03-09 23:13:09 +01:00
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
// unixSyslog opens a connection to the syslog daemon running on the
|
|
|
|
// local machine using a Unix domain socket.
|
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
func unixSyslog() (conn serverConn, err error) {
|
2011-03-09 23:13:09 +01:00
|
|
|
logTypes := []string{"unixgram", "unix"}
|
|
|
|
logPaths := []string{"/dev/log", "/var/run/syslog"}
|
|
|
|
var raddr string
|
|
|
|
for _, network := range logTypes {
|
|
|
|
for _, path := range logPaths {
|
|
|
|
raddr = path
|
2011-03-30 17:33:16 +02:00
|
|
|
conn, err := net.Dial(network, raddr)
|
2011-03-09 23:13:09 +01:00
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
} else {
|
|
|
|
return netConn{conn}, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-03 03:17:34 +01:00
|
|
|
return nil, errors.New("Unix syslog delivery error")
|
2011-03-09 23:13:09 +01:00
|
|
|
}
|