aboutsummaryrefslogtreecommitdiff
path: root/nexgb/log.go
diff options
context:
space:
mode:
authorAxel Wagner <mail@merovius.de>2013-08-23 01:16:12 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:18 +0200
commit2104b8fcdff4e444cc441f128b7f3abdcf39bbd2 (patch)
treecedfc72728c811793515b1c4edac2f24d506edd8 /nexgb/log.go
parent38b293e74db6631873d5dfd74cf731eb7b76737d (diff)
downloadhaven-2104b8fcdff4e444cc441f128b7f3abdcf39bbd2.tar.gz
haven-2104b8fcdff4e444cc441f128b7f3abdcf39bbd2.tar.xz
haven-2104b8fcdff4e444cc441f128b7f3abdcf39bbd2.zip
Export the logger (again)
Just enabling or disabling logging falls short of the power of interfaces of go. A user is forced to either accept the logging to stderr in the format defined by xgb or disable logging alltogether. By exporting the logger, we can actually let the user decide where to log in what format.
Diffstat (limited to 'nexgb/log.go')
-rw-r--r--nexgb/log.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/nexgb/log.go b/nexgb/log.go
deleted file mode 100644
index eaaa57e..0000000
--- a/nexgb/log.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package xgb
-
-import (
- "log"
- "os"
-)
-
-// Log controls whether XGB emits errors to stderr. By default, it is enabled.
-var PrintLog = true
-
-// log is a wrapper around a log.PrintLogger so we can control whether it should
-// output anything.
-type xgblog struct {
- *log.Logger
-}
-
-func newLogger() xgblog {
- return xgblog{log.New(os.Stderr, "XGB: ", log.Lshortfile)}
-}
-
-func (lg xgblog) Print(v ...interface{}) {
- if PrintLog {
- lg.Logger.Print(v...)
- }
-}
-
-func (lg xgblog) Printf(format string, v ...interface{}) {
- if PrintLog {
- lg.Logger.Printf(format, v...)
- }
-}
-
-func (lg xgblog) Println(v ...interface{}) {
- if PrintLog {
- lg.Logger.Println(v...)
- }
-}
-
-func (lg xgblog) Fatal(v ...interface{}) {
- if PrintLog {
- lg.Logger.Fatal(v...)
- } else {
- os.Exit(1)
- }
-}
-
-func (lg xgblog) Fatalf(format string, v ...interface{}) {
- if PrintLog {
- lg.Logger.Fatalf(format, v...)
- } else {
- os.Exit(1)
- }
-}
-
-func (lg xgblog) Fatalln(v ...interface{}) {
- if PrintLog {
- lg.Logger.Fatalln(v...)
- } else {
- os.Exit(1)
- }
-}
-
-func (lg xgblog) Panic(v ...interface{}) {
- if PrintLog {
- lg.Logger.Panic(v...)
- } else {
- panic("")
- }
-}
-
-func (lg xgblog) Panicf(format string, v ...interface{}) {
- if PrintLog {
- lg.Logger.Panicf(format, v...)
- } else {
- panic("")
- }
-}
-
-func (lg xgblog) Panicln(v ...interface{}) {
- if PrintLog {
- lg.Logger.Panicln(v...)
- } else {
- panic("")
- }
-}