diff options
author | 2018-11-22 19:20:38 +0100 | |
---|---|---|
committer | 2018-11-22 19:20:38 +0100 | |
commit | 8bdd41f00499b230ac00caa3bf779851da597c07 (patch) | |
tree | 8a868266b4eb84e11c591d9f3b65a0883749293a | |
parent | Django - Add Support for Storing Users Not in Guild (#150) (diff) |
Use `ERROR` log level in tests if no log level is explicitly set.
-rw-r--r-- | pysite/settings.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pysite/settings.py b/pysite/settings.py index 5badde5c..c3373250 100644 --- a/pysite/settings.py +++ b/pysite/settings.py @@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ """ import os -# import sys +import sys import environ @@ -207,7 +207,22 @@ LOGGING = { 'django': { 'handlers': ['console'], 'propagate': True, - 'level': 'INFO' if DEBUG else env('LOG_LEVEL', default='WARN') + 'level': env( + 'LOG_LEVEL', + default=( + # If there is no explicit `LOG_LEVEL` set, + # use `DEBUG` if we're running in debug mode but not + # testing. Use `ERROR` if we're running tests, else + # default to using `WARN`. + 'DEBUG' + if DEBUG and 'test' not in sys.argv + else ( + 'ERROR' + if 'test' in sys.argv + else 'WARN' + ) + ) + ) } } } |