-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2505 from cta-observatory/fix_unknown_logging
Improve logging colorization, fixes #2504
- Loading branch information
Showing
3 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix colored logging in case of custom log levels being defined. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def test_colors(): | ||
"""Test applying colors""" | ||
from ctapipe.core.logging import apply_colors | ||
|
||
assert apply_colors("DEBUG") == "\x1b[1;34mDEBUG\x1b[0m" | ||
assert apply_colors("INFO") == "\x1b[1;32mINFO\x1b[0m" | ||
assert apply_colors("WARNING") == "\x1b[1;33mWARNING\x1b[0m" | ||
assert apply_colors("ERROR") == "\x1b[1;31mERROR\x1b[0m" | ||
assert apply_colors("CRITICAL") == "\x1b[1;35mCRITICAL\x1b[0m" | ||
|
||
# unknown log-level, regression test for #2504 | ||
assert apply_colors("FOO") == "\x1b[1mFOO\x1b[0m" |