diff options
Diffstat (limited to 'src/rhimportd/main.go')
-rw-r--r-- | src/rhimportd/main.go | 19 |
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) } |