code/imports cleanup
authorBernhard Tittelbach <xro@realraum.at>
Sun, 6 Oct 2013 00:11:18 +0000 (00:11 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Sun, 6 Oct 2013 00:11:18 +0000 (00:11 +0000)
go/door_daemon_zmq/logging.go [new file with mode: 0644]

diff --git a/go/door_daemon_zmq/logging.go b/go/door_daemon_zmq/logging.go
new file mode 100644 (file)
index 0000000..b3473ed
--- /dev/null
@@ -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