2011-03-09 13:15:46 -08: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-02-16 22:04:13 -05:00
|
|
|
// +build !windows,!plan9
|
|
|
|
|
|
2011-03-09 13:15:46 -08:00
|
|
|
package syslog
|
|
|
|
|
|
|
|
|
|
import (
|
2011-11-01 22:05:34 -04:00
|
|
|
"errors"
|
2011-03-09 13:15:46 -08:00
|
|
|
"net"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// unixSyslog opens a connection to the syslog daemon running on the
|
|
|
|
|
// local machine using a Unix domain socket.
|
|
|
|
|
|
2013-02-05 09:54:01 -08:00
|
|
|
func unixSyslog() (conn net.Conn, err error) {
|
2011-03-09 13:15:46 -08:00
|
|
|
logTypes := []string{"unixgram", "unix"}
|
|
|
|
|
logPaths := []string{"/dev/log", "/var/run/syslog"}
|
|
|
|
|
for _, network := range logTypes {
|
|
|
|
|
for _, path := range logPaths {
|
2013-02-05 09:54:01 -08:00
|
|
|
conn, err := net.Dial(network, path)
|
2011-03-09 13:15:46 -08:00
|
|
|
if err != nil {
|
|
|
|
|
continue
|
|
|
|
|
} else {
|
2013-02-05 09:54:01 -08:00
|
|
|
return conn, nil
|
2011-03-09 13:15:46 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-01 22:05:34 -04:00
|
|
|
return nil, errors.New("Unix syslog delivery error")
|
2011-03-09 13:15:46 -08:00
|
|
|
}
|