Skip to content

Commit

Permalink
implement logger level checks from old PR #1044
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri-yatsenko committed Sep 16, 2024
1 parent 13aa3d5 commit b27f24c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions datajoint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ def __setitem__(self, key, value):
self._conf[key] = value
else:
raise DataJointError("Validator for {0:s} did not pass".format(key))
valid_logging_levels = {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
if key == "loglevel":
if value not in valid_logging_levels:
raise ValueError(f"{'value'} is not a valid logging value")
logger.setLevel(value)


# Load configuration from file
Expand All @@ -270,6 +275,7 @@ def __setitem__(self, key, value):
"database.password",
"external.aws_access_key_id",
"external.aws_secret_access_key",
"loglevel",
),
map(
os.getenv,
Expand All @@ -279,6 +285,7 @@ def __setitem__(self, key, value):
"DJ_PASS",
"DJ_AWS_ACCESS_KEY_ID",
"DJ_AWS_SECRET_ACCESS_KEY",
"DJ_LOG_LEVEL",
),
),
)
Expand Down

0 comments on commit b27f24c

Please sign in to comment.