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
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyaerocom/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from __future__ import annotations

import logging
import os
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

file_days="14",
file_level="DEBUG",
# pyaerocom logger
Expand Down