github.com/comwrg/go/src@v0.0.0-20220319063731-c238d0440370/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 //go:build !windows && !plan9 6 // +build !windows,!plan9 7 8 package syslog 9 10 import ( 11 "errors" 12 "net" 13 ) 14 15 // unixSyslog opens a connection to the syslog daemon running on the 16 // local machine using a Unix domain socket. 17 18 func unixSyslog() (conn serverConn, err error) { 19 logTypes := []string{"unixgram", "unix"} 20 logPaths := []string{"/dev/log", "/var/run/syslog", "/var/run/log"} 21 for _, network := range logTypes { 22 for _, path := range logPaths { 23 conn, err := net.Dial(network, path) 24 if err == nil { 25 return &netConn{conn: conn, local: true}, nil 26 } 27 } 28 } 29 return nil, errors.New("Unix syslog delivery error") 30 }