github.com/mattn/go@v0.0.0-20171011075504-07f7db3ea99f/src/log/syslog/syslog_unix.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build !windows,!nacl,!plan9
     6  
     7  package syslog
     8  
     9  import (
    10  	"errors"
    11  	"net"
    12  )
    13  
    14  // unixSyslog opens a connection to the syslog daemon running on the
    15  // local machine using a Unix domain socket.
    16  
    17  func unixSyslog() (conn serverConn, err error) {
    18  	logTypes := []string{"unixgram", "unix"}
    19  	logPaths := []string{"/dev/log", "/var/run/syslog", "/var/run/log"}
    20  	for _, network := range logTypes {
    21  		for _, path := range logPaths {
    22  			conn, err := net.Dial(network, path)
    23  			if err != nil {
    24  				continue
    25  			} else {
    26  				return &netConn{conn: conn, local: true}, nil
    27  			}
    28  		}
    29  	}
    30  	return nil, errors.New("Unix syslog delivery error")
    31  }