Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: skip unwanted logs #120

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [v1.1.1] - 2024-12-19

* [#120](https://github.com/cosmos/cosmos-db/pull/120) Skip unwanted logs from PebbleDB

## [v1.1.0] - 2024-11-22

* Allow full control in rocksdb opening
Expand Down
12 changes: 11 additions & 1 deletion pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
)

func init() {
dbCreator := func(name string, dir string, opts Options) (DB, error) {

Check failure on line 56 in pebble.go

View workflow job for this annotation

GitHub Actions / golangci

unlambda: replace `func(name string, dir string, opts Options) (DB, error) {
return NewPebbleDB(name, dir, opts)
}
registerDBCreator(PebbleDBBackend, dbCreator, false)
Expand All @@ -72,6 +72,7 @@

func NewPebbleDB(name string, dir string, opts Options) (DB, error) {
do := &pebble.Options{
Logger: &fatalLogger{}, // pebble info logs are messing up the logs (not a cosmossdk.io/log logger)
MaxConcurrentCompactions: func() int { return 3 }, // default 1
}

Expand All @@ -96,7 +97,6 @@

// Get implements DB.
func (db *PebbleDB) Get(key []byte) ([]byte, error) {
// fmt.Println("PebbleDB.Get")
if len(key) == 0 {
return nil, errKeyEmpty
}
Expand Down Expand Up @@ -232,7 +232,7 @@

// NewBatchWithSize implements DB.
// It does the same thing as NewBatch because we can't pre-allocate pebbleDBBatch
func (db *PebbleDB) NewBatchWithSize(size int) Batch {

Check failure on line 235 in pebble.go

View workflow job for this annotation

GitHub Actions / golangci

unused-parameter: parameter 'size' seems to be unused, consider removing or renaming it as _ (revive)
return newPebbleDBBatch(db)
}

Expand Down Expand Up @@ -276,7 +276,7 @@
var _ Batch = (*pebbleDBBatch)(nil)

type pebbleDBBatch struct {
db *PebbleDB

Check failure on line 279 in pebble.go

View workflow job for this annotation

GitHub Actions / golangci

field `db` is unused (unused)
batch *pebble.Batch
}

Expand All @@ -300,7 +300,7 @@
if b.batch == nil {
return errBatchClosed
}
b.batch.Set(key, value, nil)

Check failure on line 303 in pebble.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `b.batch.Set` is not checked (errcheck)
return nil
}

Expand All @@ -313,7 +313,7 @@
if b.batch == nil {
return errBatchClosed
}
b.batch.Delete(key, nil)

Check failure on line 316 in pebble.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `b.batch.Delete` is not checked (errcheck)
return nil
}

Expand Down Expand Up @@ -492,3 +492,13 @@
panic("iterator is invalid")
}
}

type fatalLogger struct {
pebble.Logger
}

func (*fatalLogger) Fatalf(format string, args ...interface{}) {
pebble.DefaultLogger.Fatalf(format, args...)
}

func (*fatalLogger) Infof(format string, args ...interface{}) {}

Check failure on line 504 in pebble.go

View workflow job for this annotation

GitHub Actions / golangci

unused-parameter: parameter 'format' seems to be unused, consider removing or renaming it as _ (revive)
Loading