Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion colorlog/escape_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down