Skip to content
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

Plugin logging on registration can't be made silent #86

Closed
elmarco opened this issue Feb 6, 2020 · 5 comments · Fixed by #88
Closed

Plugin logging on registration can't be made silent #86

elmarco opened this issue Feb 6, 2020 · 5 comments · Fixed by #88
Labels
bug Something isn't working

Comments

@elmarco
Copy link
Contributor

elmarco commented Feb 6, 2020

Hi,

When the plugins are init(), they log the registration:

[2020-02-06T14:47:46+01:00]  INFO plugins: Registering plugin "dns"
[2020-02-06T14:47:46+01:00]  INFO plugins: Registering plugin "file"
...

Unfortunately, I can't see a way to silent it, since init() is called early, before the program has the chance to change logrus behaviour. Please advise.

@pmazzini pmazzini added the bug Something isn't working label Feb 6, 2020
@elmarco
Copy link
Contributor Author

elmarco commented Feb 6, 2020

so my current workaround is to have a custom plugin/import that does:

func init() {
	log := logger.GetLogger("plugins")
	log.Logger.SetLevel(logrus.WarnLevel)
}

This is fragile as Go doesn't guaratee init() ordering in this case, afaik.

@insomniacslk
Copy link
Member

Hi @elmarco , the current method to register plugins is suboptimal, and will change. This is tracked in #45 and will let you do what you are asking here. It's faily simple to do, and I'll try to tackle it this week

@insomniacslk
Copy link
Member

insomniacslk commented Feb 6, 2020

for an example of how it could look like, see how we register plugins in another project, https://github.com/facebookincubator/contest/blob/master/cmds/contest/main.go#L90

@insomniacslk
Copy link
Member

@elmarco can you try with the latest commit? Now setting the log level globally should not print the plugin loading messages anymore.

We can also add a CLI flag for the purpose

insomniacslk added a commit that referenced this issue Feb 9, 2020
Calling CoreDHCP with -quiet will disable logging entirely.

Fixes #86

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
@elmarco
Copy link
Contributor Author

elmarco commented Feb 9, 2020

works for me, thanks

@elmarco elmarco closed this as completed Feb 9, 2020
insomniacslk added a commit that referenced this issue Feb 9, 2020
And removed -debug flag. Now all the logging levels can be specified
with -loglevel. "none" is a special log level that disables logging
altogether.

Fixes #86

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
insomniacslk added a commit that referenced this issue Feb 9, 2020
And removed -debug flag. Now all the logging levels can be specified
with -loglevel. "none" is a special log level that disables logging
altogether.

Fixes #86

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
insomniacslk added a commit that referenced this issue Feb 9, 2020
And removed -debug flag. Now all the logging levels can be specified
with -loglevel. "none" is a special log level that disables logging
altogether.

Fixes #86

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
insomniacslk added a commit that referenced this issue Feb 9, 2020
And removed -debug flag. Now all the logging levels can be specified
with -loglevel. "none" is a special log level that disables logging
altogether.

Fixes #86

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants