Ejemplo n.º 1
0
// SetLogName sets the indentifier used by syslog for this program
func SetLogName(p string) (err error) {
	if logName != nil {
		C.free(unsafe.Pointer(logName))
	}
	logName = C.CString(p)
	_, err = C.openlog(logName, C.LOG_NDELAY|C.LOG_NOWAIT|C.LOG_PID, C.LOG_USER)
	if err != nil {
		atomic.AddUint64(&errCount, 1)
	}

	return err
}
Ejemplo n.º 2
0
// Single threaded
func Syslog(ident string, priority syslog.Priority, message string) {
	// (re)open the log
	if ident != syslogIdent {
		if syslogIdent != "" {
			C.closelog()
		}

		C.openlog(C.CString(ident), LOG_NDELAY, LOG_LOCAL1)
		syslogIdent = ident
	}

	s := C.CString(message)
	C._syslog(C.int(priority), s)
	C.free(unsafe.Pointer(s))
}
Ejemplo n.º 3
0
// send sends a given string to syslog
func send(m string) error {
	if m == "" {
		return errors.New("func send received an emptry string to log.")
	}

	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))
	C.openlog(c_name, 0, facility)

	c_str := C.CString(m)
	defer C.free(unsafe.Pointer(c_str))
	C.local_syslog(priority, c_str)

	return nil
}