aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb/database.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-23 22:49:05 +0800
committerGitHub <noreply@github.com>2017-02-23 22:49:05 +0800
commit357732a8404c9fe4d02f041d20a0d05381a3e6d1 (patch)
treeedaf8a63eb7f7434cd9b9cbd764b3c4c3d76191e /ethdb/database.go
parent29fac7de448c85049a97cbec3dc0819122bd2cb0 (diff)
parentf89dd627760b43bd405cb3db1e5efdb100835db5 (diff)
downloadgo-tangerine-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.gz
go-tangerine-357732a8404c9fe4d02f041d20a0d05381a3e6d1.tar.zst
go-tangerine-357732a8404c9fe4d02f041d20a0d05381a3e6d1.zip
Merge pull request #3696 from karalabe/contextual-logger
Contextual logger
Diffstat (limited to 'ethdb/database.go')
-rw-r--r--ethdb/database.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index c0e92a87b..e82528f25 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -17,14 +17,14 @@
package ethdb
import (
+ "fmt"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
@@ -80,7 +80,7 @@ func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error) {
if handles < 16 {
handles = 16
}
- glog.V(logger.Info).Infof("Allotted %dMB cache and %d file handles to %s", cache, handles, file)
+ log.Info(fmt.Sprintf("Allotted %dMB cache and %d file handles to %s", cache, handles, file))
// Open the db and recover any potential corruptions
db, err := leveldb.OpenFile(file, &opt.Options{
@@ -167,16 +167,14 @@ func (self *LDBDatabase) Close() {
errc := make(chan error)
self.quitChan <- errc
if err := <-errc; err != nil {
- glog.V(logger.Error).Infof("metrics failure in '%s': %v\n", self.fn, err)
+ log.Error(fmt.Sprintf("metrics failure in '%s': %v\n", self.fn, err))
}
}
err := self.db.Close()
- if glog.V(logger.Error) {
- if err == nil {
- glog.Infoln("closed db:", self.fn)
- } else {
- glog.Errorf("error closing db %s: %v", self.fn, err)
- }
+ if err == nil {
+ log.Info(fmt.Sprint("closed db:", self.fn))
+ } else {
+ log.Error(fmt.Sprintf("error closing db %s: %v", self.fn, err))
}
}
@@ -231,7 +229,7 @@ func (self *LDBDatabase) meter(refresh time.Duration) {
// Retrieve the database stats
stats, err := self.db.GetProperty("leveldb.stats")
if err != nil {
- glog.V(logger.Error).Infof("failed to read database stats: %v", err)
+ log.Error(fmt.Sprintf("failed to read database stats: %v", err))
return
}
// Find the compaction table, skip the header
@@ -240,7 +238,7 @@ func (self *LDBDatabase) meter(refresh time.Duration) {
lines = lines[1:]
}
if len(lines) <= 3 {
- glog.V(logger.Error).Infof("compaction table not found")
+ log.Error(fmt.Sprintf("compaction table not found"))
return
}
lines = lines[3:]
@@ -256,7 +254,7 @@ func (self *LDBDatabase) meter(refresh time.Duration) {
}
for idx, counter := range parts[3:] {
if value, err := strconv.ParseFloat(strings.TrimSpace(counter), 64); err != nil {
- glog.V(logger.Error).Infof("compaction entry parsing failed: %v", err)
+ log.Error(fmt.Sprintf("compaction entry parsing failed: %v", err))
return
} else {
counters[i%2][idx] += value