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 log filename from environment variable #702

Merged
merged 4 commits into from
Aug 22, 2022

Conversation

avaldebe
Copy link
Collaborator

close #687

@avaldebe avaldebe added the enhancement ✨ New feature or request label Jul 13, 2022
@avaldebe avaldebe added this to the v0.13.2 milestone Jul 13, 2022
@avaldebe avaldebe self-assigned this Jul 13, 2022
@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #702 (f4692ce) into main-dev (cdb5e93) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##           main-dev     #702   +/-   ##
=========================================
  Coverage     80.04%   80.04%           
=========================================
  Files            97       97           
  Lines         17432    17433    +1     
=========================================
+ Hits          13953    13954    +1     
  Misses         3479     3479           
Flag Coverage Δ
unittests 80.04% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyaerocom/_logging.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

from importlib import resources
from logging.config import fileConfig

LOGGING_CONFIG = dict(
# root logger
file_name="pyaerocom.log",
file_name=os.getenv("PYAEROCOM_LOG_FILE", "pyaerocom.log"),
Copy link
Member

Choose a reason for hiding this comment

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

personally I would prefer to set the entire log file name via the env variable. Just like many command line tools support.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you can provide full path on PYAEROCOM_LOG_FILE

Copy link
Member

Choose a reason for hiding this comment

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

ups, I just realised that I did not understand the os.getenv method. On the other hand the Python documentation mentions this syntax (which I find clearer): os.getenv(key, default=None)
Would you mind adding the default keyword?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@avaldebe avaldebe merged commit f2ec533 into metno:main-dev Aug 22, 2022
@avaldebe avaldebe deleted the log-file branch August 22, 2022 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logging needs to use a more specific file name
2 participants