From 38cde493d2a9a1961e057fe0e175b437b3916148 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 24 Jul 2016 01:45:34 +0200 Subject: refactored logging diff --git a/debian/rhimportd.conf b/debian/rhimportd.conf index 0b38713..952aabf 100644 --- a/debian/rhimportd.conf +++ b/debian/rhimportd.conf @@ -1,5 +1,4 @@ #TELGO_DEBUG=1 -#RHIMPORT_DEBUG=1 #RHIMPORTD_DEBUG=1 RHIMPORTD_RD_CONF=/etc/rd.conf diff --git a/src/rhimportd/ctrlTelnet.go b/src/rhimportd/ctrlTelnet.go index 8ce4e83..c624654 100644 --- a/src/rhimportd/ctrlTelnet.go +++ b/src/rhimportd/ctrlTelnet.go @@ -182,7 +182,7 @@ func telnetSet(c *telgo.Client, args []string, conf *rhimport.Config, db *rddb.D var ctx *rhimport.Context if c.UserData == nil { - c.UserData = rhimport.NewContext(conf, db) + c.UserData = rhimport.NewContext(conf, db, rhl, rhdl) ctx = c.UserData.(*rhimport.Context) ctx.Trusted = false } else { diff --git a/src/rhimportd/ctrlWatchDir.go b/src/rhimportd/ctrlWatchDir.go index 2335c8f..0fd389d 100644 --- a/src/rhimportd/ctrlWatchDir.go +++ b/src/rhimportd/ctrlWatchDir.go @@ -110,7 +110,7 @@ func watchDirParseRequest(conf *rhimport.Config, db *rddb.DBChan, req *os.File) return } - ctx = rhimport.NewContext(conf, db) + ctx = rhimport.NewContext(conf, db, rhl, rhdl) ctx.UserName = reqdata.UserName ctx.Trusted = true ctx.ShowId = reqdata.ShowId diff --git a/src/rhimportd/ctrlWebSimple.go b/src/rhimportd/ctrlWebSimple.go index a44bc0f..f190f63 100644 --- a/src/rhimportd/ctrlWebSimple.go +++ b/src/rhimportd/ctrlWebSimple.go @@ -100,7 +100,7 @@ func webSimpleParseRequest(conf *rhimport.Config, db *rddb.DBChan, trusted bool, return } - ctx = rhimport.NewContext(conf, db) + ctx = rhimport.NewContext(conf, db, rhl, rhdl) if trusted { ctx.UserName = r.Header.Get("X-Forwarded-User") } else { diff --git a/src/rhimportd/ctrlWebSocket.go b/src/rhimportd/ctrlWebSocket.go index 1ce0f80..48c08fe 100644 --- a/src/rhimportd/ctrlWebSocket.go +++ b/src/rhimportd/ctrlWebSocket.go @@ -226,7 +226,7 @@ func webSocketDone(res rhimport.Result, userdata interface{}) bool { } func (self *webSocketSession) startNewSession(reqdata *webSocketRequestData, conf *rhimport.Config, sessions *rhimport.SessionStoreChan) (int, string) { - ctx := rhimport.NewContext(conf, nil) + ctx := rhimport.NewContext(conf, nil, rhl, rhdl) ctx.UserName = reqdata.UserName ctx.Password = reqdata.Password ctx.Trusted = false diff --git a/src/rhimportd/main.go b/src/rhimportd/main.go index 72785c0..4f12572 100644 --- a/src/rhimportd/main.go +++ b/src/rhimportd/main.go @@ -38,14 +38,15 @@ import ( ) var ( - rhl = log.New(os.Stderr, "[rhimportd]\t", log.LstdFlags) - rhdl = log.New(ioutil.Discard, "[rhimportd-dbg]\t", log.LstdFlags) + rhl = log.New(os.Stderr, "[std] ", log.LstdFlags) + rhdl = log.New(ioutil.Discard, "[dbg] ", log.LstdFlags) ) func init() { if _, exists := os.LookupEnv("RHIMPORTD_DEBUG"); exists { rhdl.SetOutput(os.Stderr) } + rhimport.Init(rhl, rhdl) } type envStringValue string @@ -128,7 +129,7 @@ func main() { } defer db.Cleanup() - sessions, err := rhimport.NewSessionStore(conf, db.GetInterface()) + sessions, err := rhimport.NewSessionStore(conf, db.GetInterface(), rhl, rhdl) if err != nil { rhl.Println("Error initializing Session Store:", err) return -- cgit v0.10.2