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

Set default log level via config #1987

Merged
merged 3 commits into from
Jan 18, 2017
Merged

Conversation

riga
Copy link
Contributor

@riga riga commented Jan 16, 2017

Description

This PR allows for the configuration of the default log level, which is DEBUG by default.

Motivation and Context

It might be a first world problem, but sometimes it would be nice to control the default log level without the need to create (and deploy) a logging config file, but rather by a simple environment variable. The value of this variable must match the name of a python logging level. Usage example:

LUIGI_DEFAULT_LOG_LEVEL=INFO luigi --module my_module MyTask --x 123

An other option would be to add default_log_level to the core config and to prefer the environment variable if set (at least that's what most libs do).

Tests

Too trivial to test :P

Docs

I couldn't find a place in the docs for this feature, but I sure can add a sentence or two to a section of your choice.

@mention-bot
Copy link

@riga, thanks for your PR! By analyzing the history of the files in this pull request, we identified @dlstadther, @themalkolm and @Tarrasch to be potential reviewers.

Copy link
Contributor

@Tarrasch Tarrasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason you don't set this using the core config class? Then it could be automatically documented through the --help flag. Also, a ChoiceParameter would check that you don't misspell the logging levels.

Would you consider to refactor into such an implementation?

@Tarrasch
Copy link
Contributor

Overall awesome patch. I have wanted this too sometimes. :)

Oh, bonus points if you assert that if there's a config set to read the logging-config, then luigi shouldn't allow one to set this new config variable as it will not take affect.

@riga
Copy link
Contributor Author

riga commented Jan 17, 2017

Like that?

@riga riga changed the title Set default log level via env variable Set default log level via config Jan 17, 2017
@Tarrasch
Copy link
Contributor

Exactly like that. :)

@Tarrasch Tarrasch merged commit e7ad199 into spotify:master Jan 18, 2017
@Tarrasch
Copy link
Contributor

Thanks @riga! :)

kreczko pushed a commit to kreczko/luigi that referenced this pull request Mar 28, 2017
Add default log level to core config and update docs.
This was referenced Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants