예제 #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
}
예제 #2
0
파일: syslog.go 프로젝트: streadway/gobark
// 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))
}
예제 #3
0
파일: slog.go 프로젝트: d4wnr4z0r/go-pkgs
// 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
}