diff --git a/ldb/leveldb.go b/ldb/leveldb.go index 063f115b..0f88ed5a 100644 --- a/ldb/leveldb.go +++ b/ldb/leveldb.go @@ -8,12 +8,12 @@ import ( "encoding/binary" "fmt" "github.com/conformal/btcdb" + "github.com/conformal/btclog" "github.com/conformal/btcutil" "github.com/conformal/btcwire" "github.com/conformal/goleveldb/leveldb" "github.com/conformal/goleveldb/leveldb/cache" "github.com/conformal/goleveldb/leveldb/opt" - "github.com/conformal/seelog" "os" "sync" ) @@ -24,7 +24,7 @@ const ( dbMaxTransMem = 64 * 1024 * 1024 // 64 MB ) -var log seelog.LoggerInterface = seelog.Disabled +var log = btclog.Disabled type tTxInsertData struct { txsha *btcwire.ShaHash diff --git a/log.go b/log.go index 667e0bcb..b6baf052 100644 --- a/log.go +++ b/log.go @@ -6,14 +6,14 @@ package btcdb import ( "errors" - "github.com/conformal/seelog" + "github.com/conformal/btclog" "io" ) // log is a logger that is initialized with no output filters. This // means the package will not perform any logging by default until the caller // requests it. -var log seelog.LoggerInterface +var log btclog.Logger // The default amount of logging is none. func init() { @@ -21,28 +21,33 @@ func init() { } // DisableLog disables all library log output. Logging output is disabled -// by default until either UserLogger or SetLogWriter are called. +// by default until either UseLogger or SetLogWriter are called. func DisableLog() { - log = seelog.Disabled + log = btclog.Disabled } // UseLogger uses a specified Logger to output package logging info. // This should be used in preference to SetLogWriter if the caller is also -// using seelog. -func UseLogger(logger seelog.LoggerInterface) { +// using btclog. +func UseLogger(logger btclog.Logger) { log = logger } // SetLogWriter uses a specified io.Writer to output package logging info. // This allows a caller to direct package logging output without needing a -// dependency on seelog. If the caller is also using seelog, UseLogger should +// dependency on seelog. If the caller is also using btclog, UseLogger should // be used instead. -func SetLogWriter(w io.Writer) error { +func SetLogWriter(w io.Writer, level string) error { if w == nil { return errors.New("nil writer") } - l, err := seelog.LoggerFromWriterWithMinLevel(w, seelog.TraceLvl) + lvl, ok := btclog.LogLevelFromString(level) + if !ok { + return errors.New("invalid log level") + } + + l, err := btclog.NewLoggerFromWriter(w, lvl) if err != nil { return err } @@ -52,6 +57,6 @@ func SetLogWriter(w io.Writer) error { } // GetLog returns the currently active logger. -func GetLog() seelog.LoggerInterface { +func GetLog() btclog.Logger { return log } diff --git a/memdb/driver.go b/memdb/driver.go index 1304dc77..e225e687 100644 --- a/memdb/driver.go +++ b/memdb/driver.go @@ -6,10 +6,10 @@ package memdb import ( "github.com/conformal/btcdb" - "github.com/conformal/seelog" + "github.com/conformal/btclog" ) -var log = seelog.Disabled +var log = btclog.Disabled func init() { driver := btcdb.DriverDB{DbType: "memdb", Create: CreateDB, Open: OpenDB} diff --git a/sqlite3/sqlite.go b/sqlite3/sqlite.go index 364c98d4..0cb3fc61 100644 --- a/sqlite3/sqlite.go +++ b/sqlite3/sqlite.go @@ -8,9 +8,9 @@ import ( "database/sql" "fmt" "github.com/conformal/btcdb" + "github.com/conformal/btclog" "github.com/conformal/btcutil" "github.com/conformal/btcwire" - "github.com/conformal/seelog" _ "github.com/mattn/go-sqlite3" "os" "sync" @@ -88,7 +88,7 @@ var txqueries []string = []string{ txtmpExistsShaStmt: "SELECT blockid FROM txtmp WHERE key = ?;", } -var log seelog.LoggerInterface = seelog.Disabled +var log = btclog.Disabled type tBlockInsertData struct { sha btcwire.ShaHash