Black Lives Matter. Support the Equal Justice Initiative.

Source file src/log/syslog/syslog_unix.go

Documentation: log/syslog

     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  }
    31  

View as plain text