summaryrefslogtreecommitdiff
path: root/src/rhimportd/main.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-24 01:08:23 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-24 01:08:23 (GMT)
commitb94feddead6ebb906b17a797477f2d0ff989832e (patch)
tree7da558d83bbc64b3f27a4b8b4caefc4aff2d0bd8 /src/rhimportd/main.go
parent38cde493d2a9a1961e057fe0e175b437b3916148 (diff)
client/session specific log prefixes
Diffstat (limited to 'src/rhimportd/main.go')
-rw-r--r--src/rhimportd/main.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/rhimportd/main.go b/src/rhimportd/main.go
index 4f12572..6c68962 100644
--- a/src/rhimportd/main.go
+++ b/src/rhimportd/main.go
@@ -37,15 +37,24 @@ import (
"time"
)
+func getStdLog(name string) *log.Logger {
+ return log.New(os.Stderr, "["+name+"] ", log.LstdFlags)
+}
+
+func getDbgLog(name string) *log.Logger {
+ dbg := log.New(ioutil.Discard, "["+name+"] ", log.LstdFlags)
+ if _, exists := os.LookupEnv("RHIMPORTD_DEBUG"); exists {
+ dbg.SetOutput(os.Stderr)
+ }
+ return dbg
+}
+
var (
- rhl = log.New(os.Stderr, "[std] ", log.LstdFlags)
- rhdl = log.New(ioutil.Discard, "[dbg] ", log.LstdFlags)
+ rhl = getStdLog("std")
+ rhdl = getDbgLog("dbg")
)
func init() {
- if _, exists := os.LookupEnv("RHIMPORTD_DEBUG"); exists {
- rhdl.SetOutput(os.Stderr)
- }
rhimport.Init(rhl, rhdl)
}