-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: add logger package #14872
Merged
Merged
refactor: add logger package #14872
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9ab67ad
add logger package
tac0turtle ce8a6ab
Merge branch 'main' into marko/logger_pacakge
tac0turtle ab3bd92
fix gofumpt
tac0turtle 386a02e
add various tooling
tac0turtle c40e7e3
Merge branch 'main' into marko/logger_pacakge
tac0turtle 6dfac2f
add label and depndabot
tac0turtle c8a0f2d
move and fix
tac0turtle feee155
remove cache due to no go.sum
tac0turtle 9ed8266
Update log/logger.go
tac0turtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,5 @@ | |
- store/**/* | ||
"C:orm": | ||
- orm/**/* | ||
"C:log": | ||
- log/* |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ use ( | |
./core | ||
./depinject | ||
./errors | ||
./log | ||
./math | ||
./orm | ||
./simapp | ||
|
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,32 @@ | ||
<!-- | ||
Guiding Principles: | ||
|
||
Changelogs are for humans, not machines. | ||
There should be an entry for every single version. | ||
The same types of changes should be grouped. | ||
Versions and sections should be linkable. | ||
The latest version comes first. | ||
The release date of each version is displayed. | ||
Mention whether you follow Semantic Versioning. | ||
|
||
Usage: | ||
|
||
Change log entries are to be added to the Unreleased section under the | ||
appropriate stanza (see below). Each entry should ideally include a tag and | ||
the Github issue reference in the following format: | ||
|
||
* (<tag>) [#<issue-number>] Changelog message. | ||
|
||
Types of changes (Stanzas): | ||
|
||
"Features" for new features. | ||
"Improvements" for changes in existing functionality. | ||
"Deprecated" for soon-to-be removed features. | ||
"Bug Fixes" for any bug fixes. | ||
"API Breaking" for breaking exported APIs used by developers building on SDK. | ||
Ref: https://keepachangelog.com/en/1.0.0/ | ||
--> | ||
|
||
# Changelog | ||
|
||
## [Unreleased] |
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,3 @@ | ||
module github.com/cosmos/cosmos-sdk/log | ||
|
||
go 1.19 |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package log | ||
|
||
// Service is the interface that wraps the basic logging methods. | ||
type Service interface { | ||
// Logger is the interface that wraps the basic logging methods. | ||
type Logger interface { | ||
Debug(msg string, keyvals ...interface{}) | ||
Info(msg string, keyvals ...interface{}) | ||
Error(msg string, keyvals ...interface{}) | ||
|
||
With(keyvals ...interface{}) Service | ||
With(keyvals ...interface{}) Logger | ||
} |
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,17 @@ | ||
package log | ||
|
||
var _ Logger = &NoOp{} | ||
|
||
type NoOp struct{} | ||
|
||
func NewNoOpLogger() *NoOp { | ||
return &NoOp{} | ||
} | ||
|
||
func (l NoOp) Debug(msg string, keyvals ...interface{}) {} | ||
func (l NoOp) Info(msg string, keyvals ...interface{}) {} | ||
func (l NoOp) Error(msg string, keyvals ...interface{}) {} | ||
|
||
func (l NoOp) With(i ...interface{}) Logger { | ||
return l | ||
} |
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,14 @@ | ||
sonar.projectKey=cosmos-sdk-log | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created 👍🏾 -> https://sonarcloud.io/project/overview?id=cosmos-sdk-log |
||
sonar.organization=cosmos | ||
|
||
sonar.projectName=Cosmos SDK - Log | ||
sonar.project.monorepo.enabled=true | ||
|
||
sonar.sources=. | ||
sonar.exclusions=**/*_test.go | ||
sonar.tests=. | ||
sonar.test.inclusions=**/*_test.go | ||
sonar.go.coverage.reportPaths=coverage.out | ||
|
||
sonar.sourceEncoding=UTF-8 | ||
sonar.scm.provider=git |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that it is a small PR, could you add all the tooling too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got it all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one typo, and could you add it to dependabot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make it
cosmossdk.io/log
? Why not just have this interface in core? I think there should be a core logging serviceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought core should not be containing any implementation.
If you had an interface in core and the implementation in logger that's a bit weird. Imo better to keep close the interface from its implementation for small packages like that.
Agrees that a vanity url is better however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a no-op implementation in core is fine. That's all this has right? I don't have a strong preference on whether it goes in core, but I do think modules will want a logging service so that should probably go in core right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but maybe in that log package we can add a function for these logger too, so we don't duplicate other loggers:
This was what makes the most sense to me, imo as this does not fit in core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that probably shouldn't be in core. So if we can have a simple interface with zero dependencies, the same interface can exist in core and log. Log can provide some implementations like zerolog and comet. And core can have the same interface for the service but no implementations. The main thing I think is getting rid of the dependency on comet as I mentioned here #14904 (comment)