-
Notifications
You must be signed in to change notification settings - Fork 44
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
chore: Add configuration of external loggers #942
chore: Add configuration of external loggers #942
Conversation
// goLogger is a wrapper for a go-log logger | ||
// Used by github.com/ipfs/go-ipfs-provider | ||
type goLogger struct { | ||
*logger | ||
*golog.ZapEventLogger | ||
} | ||
|
||
func GetGoLogger(name string) *goLogger { | ||
l := mustNewLogger(name) | ||
gl := golog.Logger(name) | ||
return &goLogger{ | ||
logger: l, | ||
ZapEventLogger: gl, | ||
} | ||
} | ||
|
||
func (l *goLogger) ApplyConfig(config Config) { | ||
l.logger.ApplyConfig(config) | ||
l.ZapEventLogger.SugaredLogger = *l.logger.logger.Sugar() | ||
} |
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.
question: The wrapper code seems fairly similar for both the loggers, what is the difference between the loggers?
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.
They are pretty much the same. It's just that both are imported so both need to be handled as they have their own package specific map of registered loggers.
Codecov Report
@@ Coverage Diff @@
## develop #942 +/- ##
===========================================
+ Coverage 60.30% 60.34% +0.03%
===========================================
Files 164 164
Lines 17712 17732 +20
===========================================
+ Hits 10682 10701 +19
- Misses 6082 6083 +1
Partials 948 948
|
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.
LGTM, but I suggest (non-blocking) to add a comment addressing adding external loggers that lead to ambiguous selectors - when the external logger's funcs/fields conflicts with the internal logger's interface (if I'm understanding this correctly).
Thanks. As for your suggestion, I'm not sure it's relevant. We don't care about the funcs/fields of the external logger. All we care about is ensuring it takes the configs that we send it. If you think I'm misunderstanding please let me know and maybe add a bit more details so I can get a better idea. |
All I'm suggesting is to add one comment guiding the future developer adding an external logger there - if you see that as valuable. |
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.
LGTM
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.
LGTM
4b5f34f
to
98d08e3
Compare
comment added. |
Relevant issue(s) Resolves sourcenetwork#729 Resolves sourcenetwork#710 Description This PR adds support for external loggers. Specifically go-log (imported by a dependancy) and go-log V2 (imported by datastore/badger/v3). It adds a mechanism to update the external logger with the provided configuration.
Relevant issue(s)
Resolves #729
Resolves #710
Description
This PR adds support for external loggers. Specifically go-log (imported by a dependancy) and go-log V2 (imported by datastore/badger/v3). It adds a mechanism to update the external logger with the provided configuration.
Tasks
How has this been tested?
unit test and visual
Specify the platform(s) on which this was tested: