-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(v2): use non global logger (#1037)
- Loading branch information
1 parent
b3c241c
commit 0bce70d
Showing
16 changed files
with
200 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
|
||
## Unreleased | ||
|
||
* [#1037](https://github.com/cosmos/iavl/pull/1037) Swap `zerolog` for internal logger interface | ||
|
||
## [v2.0.0-alpha.4](https://github.com/cosmos/iavl/releases/tag/v2.0.0-alpha.4) | ||
|
||
* Remove debug prints | ||
|
||
## [v2.0.0-alpha.3](https://github.com/cosmos/iavl/releases/tag/v2.0.0-alpha.3) | ||
|
||
* Initial tag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# IAVL v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package iavl | ||
|
||
import "log/slog" | ||
|
||
// Logger defines basic logger that IAVL expects. | ||
// It is a subset of the cosmossdk.io/core/log.Logger interface. | ||
// cosmossdk.io/log/log.Logger implements this interface. | ||
type Logger interface { | ||
// Info takes a message and a set of key/value pairs and logs with level INFO. | ||
// The key of the tuple must be a string. | ||
Info(msg string, keyVals ...any) | ||
|
||
// Warn takes a message and a set of key/value pairs and logs with level WARN. | ||
// The key of the tuple must be a string. | ||
Warn(msg string, keyVals ...any) | ||
|
||
// Error takes a message and a set of key/value pairs and logs with level ERR. | ||
// The key of the tuple must be a string. | ||
Error(msg string, keyVals ...any) | ||
|
||
// Debug takes a message and a set of key/value pairs and logs with level DEBUG. | ||
// The key of the tuple must be a string. | ||
Debug(msg string, keyVals ...any) | ||
} | ||
|
||
// NewNopLogger returns a new logger that does nothing. | ||
func NewNopLogger() Logger { | ||
return &noopLogger{} | ||
} | ||
|
||
type noopLogger struct{} | ||
|
||
func (l *noopLogger) Info(string, ...any) {} | ||
func (l *noopLogger) Warn(string, ...any) {} | ||
func (l *noopLogger) Error(string, ...any) {} | ||
func (l *noopLogger) Debug(string, ...any) {} | ||
|
||
func NewTestLogger() Logger { | ||
return &testLogger{} | ||
} | ||
|
||
type testLogger struct{} | ||
|
||
func (l *testLogger) Info(msg string, keys ...any) { | ||
slog.Info(msg, keys...) | ||
} | ||
func (l *testLogger) Warn(msg string, keys ...any) { | ||
slog.Warn(msg, keys...) | ||
} | ||
func (l *testLogger) Error(msg string, keys ...any) { | ||
slog.Error(msg, keys...) | ||
} | ||
func (l *testLogger) Debug(msg string, keys ...any) { | ||
slog.Debug(msg, keys...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.