diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-23 23:45:59 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-24 01:02:55 (GMT) |
commit | fcfe5720506f4015e4e65c62f7a9d22c4ee44913 (patch) | |
tree | 7efc06f219b858d7061a5355c0e1d3ae758ca969 /rhimport/core.go | |
parent | 6df513e9c221fdc16abc53075e3c6bc84804f014 (diff) |
no seperate log for lib anymore - use logger from host application instead
Diffstat (limited to 'rhimport/core.go')
-rw-r--r-- | rhimport/core.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/rhimport/core.go b/rhimport/core.go index f1bbe16..a0f1060 100644 --- a/rhimport/core.go +++ b/rhimport/core.go @@ -53,17 +53,11 @@ const ( var ( bool2str = map[bool]string{false: "0", true: "1"} - rhl = log.New(os.Stderr, "[rhimport]\t", log.LstdFlags) - rhdl = log.New(ioutil.Discard, "[rhimport-dbg]\t", log.LstdFlags) ) -func init() { - if _, exists := os.LookupEnv("RHIMPORT_DEBUG"); exists { - rhdl.SetOutput(os.Stderr) - } - +func Init(stdlog, dbglog *log.Logger) { curl.GlobalInit(curl.GLOBAL_ALL) - fetcherInit() + fetcherInit(stdlog, dbglog) } type ProgressCB func(step int, stepName string, current, total float64, title string, cart, cut uint, userdata interface{}) bool @@ -134,6 +128,8 @@ type AttachmentChunk struct { type Context struct { conf *Config db *rddb.DBChan + stdlog *log.Logger + dbglog *log.Logger UserName string Password string Trusted bool @@ -163,10 +159,19 @@ type Context struct { Cancel <-chan bool } -func NewContext(conf *Config, db *rddb.DBChan) *Context { +func NewContext(conf *Config, db *rddb.DBChan, stdlog, dbglog *log.Logger) *Context { + if stdlog == nil { + stdlog = log.New(ioutil.Discard, "", 0) + } + if dbglog == nil { + dbglog = log.New(ioutil.Discard, "", 0) + } + ctx := new(Context) ctx.conf = conf ctx.db = db + ctx.stdlog = stdlog + ctx.dbglog = dbglog ctx.UserName = "" ctx.Password = "" ctx.Trusted = false |