Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # 'FATAL CRITICAL ERROR WARNING INFO DEBUG NOTSET' |
||
2 | _RECORD = { |
||
3 | 'FATAL': '\033[00;31m', # Strong Red |
||
4 | 'CRITICAL': '\033[00;31m', # Strong Red |
||
5 | 'ERROR': '\033[01;31m', # Red |
||
6 | 'WARNING': '\033[01;33m', # Yellow |
||
7 | 'INFO': '\033[01;32m', # Green |
||
8 | 'DEBUG': '', |
||
9 | 'NOTSET': '\033[01;34m', # Blue |
||
10 | } |
||
11 | |||
12 | _MESSAGE = { |
||
13 | 'FATAL': '\033[1m', |
||
14 | 'CRITICAL': '', |
||
15 | 'ERROR': '\033[1m', |
||
16 | 'WARNING': '\033[1m', |
||
17 | 'INFO': '\033[1m', |
||
18 | 'DEBUG': '', |
||
19 | 'NOTSET': '', |
||
20 | } |
||
21 | |||
22 | _END = '\033[0m' |
||
23 | |||
24 | |||
25 | def source(level, message): |
||
26 | color = _RECORD.get(level, '') |
||
27 | if color: |
||
28 | return f'{color}{message:<13}{_END}' |
||
29 | return message |
||
30 | |||
31 | |||
32 | def message(level, message): |
||
33 | color = _MESSAGE.get(level, '') |
||
34 | if color: |
||
35 | return f'{color}{message:<8}{_END}' |
||
36 | return message |
||
37 |