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

Selectively set the log level of sources from the CLI #37

Open
MisterDA opened this issue Oct 4, 2021 · 2 comments
Open

Selectively set the log level of sources from the CLI #37

MisterDA opened this issue Oct 4, 2021 · 2 comments

Comments

@MisterDA
Copy link

MisterDA commented Oct 4, 2021

In my app, I have two sources of logging, Tamino and Papageno. I use logs.cli to setup the logging of my app in a similar fashion as the example. However, in debug mode, Papageno is extremely verbose and I'm much more interested by what Tamino has to say. Could it be possible to extend the API and find some way to set the verbosity of sources from the command-line interface? I can always add code to disable debug output from Papageno, but that's what I was trying to avoid by switching to logs.cli.
As I understand the API, logs.cli should not set the verbosity of sources directly, but rather return the verbosity set by the user, so it might be difficult to extend the current API (Logs_cli.level) or come up with a new function.
Regarding the actual command-line interface, I think it could look like this:

app --verbosity=debug	# set the debug level for each source
app --verbosity=tamino:debug	# set the verbosity of Tamino to debug. Pamino has the default level.
app --tamino-verbosity=debug	# other syntax proposal
app --verbosity=tamino:debug,pamino:info
app --verbosity=tamino:debug --verbosity=pamino:info
app --tamino-verbosity=debug --pamino-verbosity=info

What style looks the "sanest" to you? I think that only the verbosity flag needs the name expansion.

@dbuenzli
Copy link
Owner

dbuenzli commented Oct 4, 2021

What style looks the "sanest" to you?

I think I would go with --verbosity=LEVEL[,SRC:LEVEL]…

Did you look around if there may be existing syntax to copycat from (e.g. journalctl or whatever) ?

@MisterDA
Copy link
Author

MisterDA commented Oct 4, 2021

What style looks the "sanest" to you?

I think I would go with --verbosity=LEVEL[,SRC:LEVEL]…

That's quite nice!

Did you look around if there may be existing syntax to copycat from (e.g. journalctl or whatever) ?

journalctl doesn't seem to be able to do that. I can see that it can select multiple sources (-t or -u flags) but the -p flag to select the level is global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants