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.
|
|
|
|
|
2014-07-19 10:53:52 +02:00
|
|
|
// +build !windows,!nacl,!plan9
|
2012-03-02 21:01:37 +01:00
|
|
|
|
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.
|
|
|
|
|
2013-07-23 23:23:27 +02:00
|
|
|
func unixSyslog() (conn serverConn, err error) {
|
2011-03-09 23:13:09 +01:00
|
|
|
logTypes := []string{"unixgram", "unix"}
|
2015-01-15 01:27:56 +01:00
|
|
|
logPaths := []string{"/dev/log", "/var/run/syslog", "/var/run/log"}
|
2011-03-09 23:13:09 +01:00
|
|
|
for _, network := range logTypes {
|
|
|
|
for _, path := range logPaths {
|
2013-07-16 08:54:42 +02:00
|
|
|
conn, err := net.Dial(network, path)
|
2011-03-09 23:13:09 +01:00
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
} else {
|
2013-11-06 20:49:01 +01:00
|
|
|
return &netConn{conn: conn, local: true}, nil
|
2011-03-09 23:13:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-03 03:17:34 +01:00
|
|
|
return nil, errors.New("Unix syslog delivery error")
|
2011-03-09 23:13:09 +01:00
|
|
|
}
|