syslog_unix.go 775 Bytes
Newer Older
1 2 3 4
// 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.

5
// +build !windows,!nacl,!plan9,!solaris,!irix
6

7 8 9
package syslog

import (
10
	"errors"
11 12 13 14 15 16
	"net"
)

// unixSyslog opens a connection to the syslog daemon running on the
// local machine using a Unix domain socket.

17
func unixSyslog() (conn serverConn, err error) {
18
	logTypes := []string{"unixgram", "unix"}
19
	logPaths := []string{"/dev/log", "/var/run/syslog", "/var/run/log"}
20 21
	for _, network := range logTypes {
		for _, path := range logPaths {
22
			conn, err := net.Dial(network, path)
23
			if err == nil {
24
				return &netConn{conn: conn, local: true}, nil
25 26 27
			}
		}
	}
28
	return nil, errors.New("Unix syslog delivery error")
29
}