-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
493d486
commit 97c9bbb
Showing
10 changed files
with
61 additions
and
58 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
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,30 @@ | ||
package log | ||
|
||
// Logger is the Cosmos SDK logger interface. | ||
// It maintains as much backward compatibility with the CometBFT logger as possible. | ||
// All functionalities of the logger are available through the Impl() method. | ||
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) | ||
|
||
// With returns a new wrapped logger with additional context provided by a set. | ||
With(keyVals ...any) Logger | ||
|
||
// Impl returns the underlying logger implementation. | ||
// It is used to access the full functionalities of the underlying logger. | ||
// Advanced users can type cast the returned value to the actual logger. | ||
Impl() any | ||
} |
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,19 @@ | ||
package log | ||
|
||
// NewNopLogger returns a new logger that does nothing. | ||
func NewNopLogger() Logger { | ||
// The custom nopLogger is about 3x faster than a zeroLogWrapper with zerolog.Nop(). | ||
return nopLogger{} | ||
} | ||
|
||
// nopLogger is a Logger that does nothing when called. | ||
// See the "specialized nop logger" benchmark and compare with the "zerolog nop logger" benchmark. | ||
// The custom implementation is about 3x faster. | ||
type nopLogger struct{} | ||
|
||
func (nopLogger) Info(string, ...any) {} | ||
func (nopLogger) Warn(string, ...any) {} | ||
func (nopLogger) Error(string, ...any) {} | ||
func (nopLogger) Debug(string, ...any) {} | ||
func (nopLogger) With(...any) Logger { return nopLogger{} } | ||
func (nopLogger) Impl() any { return nopLogger{} } |
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