summaryrefslogtreecommitdiff
path: root/rhimport/core.go
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport/core.go')
-rw-r--r--rhimport/core.go23
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