From: Bernhard Tittelbach Date: Sun, 6 Oct 2013 00:11:18 +0000 (+0000) Subject: code/imports cleanup X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=21d793709bb0e938ca7bf3f63ddc3421282e50b9;p=svn42.git code/imports cleanup --- diff --git a/go/door_daemon_zmq/logging.go b/go/door_daemon_zmq/logging.go new file mode 100644 index 0000000..b3473ed --- /dev/null +++ b/go/door_daemon_zmq/logging.go @@ -0,0 +1,31 @@ +// (c) Bernhard Tittelbach, 2013 + +package main + +import "os" +import "log" +import "log/syslog" + +type NullWriter struct {} +func (n *NullWriter) Write(p []byte) (int, error) {return len(p),nil} + +var ( + Syslog_ *log.Logger + Debug_ *log.Logger +) + +func init() { + Syslog_ = log.New(&NullWriter{}, "", 0) + Debug_ = log.New(&NullWriter{}, "", 0) +} + +func LogEnableSyslog() { + var logerr error + Syslog_, logerr = syslog.NewLogger(syslog.LOG_INFO | (18<<3), 0) + if logerr != nil { panic(logerr) } +} + +func LogEnableDebuglog() { + Syslog_ = log.New(os.Stdout, "", log.LstdFlags) + Debug_ = log.New(os.Stderr, "DEBUG ", log.LstdFlags) +} \ No newline at end of file