-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[FEATURE] allow passing custom logger to "server" component #2556
Comments
Thanks for the feature request, PRs are definitely most welcome. In this case, however, the service uses The easy solution here would be to separate your services out in one per runtime. Edit: you can ofcourse specify the logger by manually overriding that value |
Thanks for your feedback
The thing is about logger, is that we need to customize them even in the same runtime/microservice, usage example, when filtering logs of the broker client component, i may need to use a specific field (ex: broker) or for the store component or any other component use in microservice.
i have read the codebase, What do you think ? |
Your use case makes sense. Definitely open to better implementations. Well written PR is welcome. Looking forward to see your implementation :) @xpunch thoughs on this ? Edit: one note here, is that to use custom loggers per interface (store, registry, broker etc.) All plugins need to be rewritten alongside of the new options to use them. Perhaps we can by default auto derive an extra field to denote the interface type as you suggested |
@Davincible the fallback to in order for me to introduce this feature, i'll create two PRs, one for go-micro, second for plugins after go-micro release. |
The logger can be abstracted as a configurable component like registry, store, broker etc. |
Still there's a global containing the Logger for the current runtime? I believe @asynxc want's to replace the global with a Logger per instance. |
@pcdummy global logger won't be removed, see the PR for details. It's only used as a fall back |
@xpunch if you make the logger only one configurable component it's still global, just not in a global variable. By allowing to pass in loggers through options you can set a different logger for different components (broker, registry etc.), so you can add custom fields to each logger, which what asynxc is looking for |
@Davincible I got your point, logging is very important in micro service systems. Different component or plugins may need different logger, maybe we need to re-design the whole logging modules in go micro. |
…aultLogger) closes #2556 (#2559) * feat(logger): add logger option to all components * fix: refactor api/rpc.go * fix: refactor api/stream.go * fix: api/options.go comment * fix(logger): do not use logger.Helper internally * fix(logger): fix comments * fix(logger): use level.Enabled method * fix: rename mlogger to log * fix: run go fmt * fix: log level * fix: factories Co-authored-by: Mohamed MHAMDI <[email protected]> Co-authored-by: Davincible <[email protected]>
Is your feature request related to a problem? Please describe.
in a context where we instantiate multiple server in same process, we may need to assign specific fields to each instance.
So that it's easier to distinguish their logs.
Describe the solution you'd like
add new option
server.WithLogger(logger log.Logger)
to server optionsIf this's ok with you, i can create a PR in both go-micro and plugins projects ?
The text was updated successfully, but these errors were encountered: