From 6c9d5c277bbe48761cbfdbbb37d4c3dcb41e864b Mon Sep 17 00:00:00 2001 From: vadimsachkov Date: Tue, 22 Sep 2020 16:04:51 +0300 Subject: [PATCH] 20200922 --- colorlog/escape_codes.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/colorlog/escape_codes.py b/colorlog/escape_codes.py index 74c5071..a132443 100644 --- a/colorlog/escape_codes.py +++ b/colorlog/escape_codes.py @@ -52,7 +52,19 @@ def esc(*x): ] for prefix, prefix_name in PREFIXES: - for code, name in enumerate(COLORS): + # Create a 256-color dictionary. Use as example: 'INFO': 'bg_bold_c12', + # where the 'c' character is just a prefix (abbreviated from color) and 12 is a number from 0 to 255 + # example: + # log_colors={ + # 'DEBUG': 'blue', + # 'INFO': 'bold_c12', + # 'WARNING': 'c240', + # 'ERROR': 'bg_bold_c48', + # 'CRITICAL': 'red,bg_c0', + #} + colors256={f'8;5;{i}':f'c{i}' for i in range(255)} + colors256.update(enumerate(COLORS)) + for code, name in colors256.items(): escape_codes[prefix_name + name] = esc(prefix + str(code))