Skip to content

Commit

Permalink
Add "ERROR" level to logging (duartegroup#231)
Browse files Browse the repository at this point in the history
* add ERROR level to logging

* update docs for logging

* update tests for logging

* update changelog
  • Loading branch information
shoubhikraj authored Jan 23, 2023
1 parent bd57493 commit be4c9a8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 4 additions & 1 deletion autode/log/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""
Set up logging with the standard python logging module. Set the log level with
$AUTODE_LOG_LEVEL = {'', INFO, WARNING, DEBUG}
$AUTODE_LOG_LEVEL = {'', ERROR, WARNING, INFO, DEBUG}
i.e. export AUTODE_LOG_LEVEL=DEBUG
Expand Down Expand Up @@ -36,6 +36,9 @@ def get_log_level():
if log_level_str == "INFO":
return logging.INFO

if log_level_str == "ERROR":
return logging.ERROR

return logging.CRITICAL


Expand Down
19 changes: 19 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
Changelog
=========

1.3.5
--------
----------


Usability improvements/Changes
******************************
*


Functionality improvements
**************************
-


Bug Fixes
*********
- Fixes :code:`ERROR` logging level being ignored from environment variable :code:`AUTODE_LOG_LEVEL`

1.3.4
--------
----------
Expand Down
2 changes: 1 addition & 1 deletion doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ to see all the options.
Logging
-------

To set the logging level to one of {INFO, WARNING, ERROR} set the :code:`AUTODE_LOG_LEVEL`
To set the logging level to one of {DEBUG, INFO, WARNING, ERROR} set the :code:`AUTODE_LOG_LEVEL`
environment variable, in bash::

$ export AUTODE_LOG_LEVEL=INFO
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Logging
Logging
-------

To set the logging level to one of {INFO, WARNING, ERROR} set the AUTODE_LOG_LEVEL
To set the logging level to one of {DEBUG, INFO, WARNING, ERROR} set the AUTODE_LOG_LEVEL
environment variable, in bash::

$ export AUTODE_LOG_LEVEL=INFO
3 changes: 3 additions & 0 deletions tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def test_log_level():
os.environ["AUTODE_LOG_LEVEL"] = "DEBUG"
assert log.get_log_level() == log.logging.DEBUG

os.environ["AUTODE_LOG_LEVEL"] = "ERROR"
assert log.get_log_level() == log.logging.ERROR

os.environ["AUTODE_LOG_LEVEL"] = "WARNING"
assert log.get_log_level() == log.logging.WARNING

Expand Down

0 comments on commit be4c9a8

Please sign in to comment.