From 21d793709bb0e938ca7bf3f63ddc3421282e50b9 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sun, 6 Oct 2013 00:11:18 +0000 Subject: [PATCH 1/1] code/imports cleanup --- go/door_daemon_zmq/logging.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 go/door_daemon_zmq/logging.go 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 -- 1.7.10.4