- Better error reporting.
- Flask now uses application's logger instead of its own. - ucloud file scanner refactored.
This commit is contained in:
parent
eea6c1568e
commit
972bb5a920
14 changed files with 157 additions and 154 deletions
24
ucloud/common/logging.py
Normal file
24
ucloud/common/logging.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import logging
|
||||
import colorama
|
||||
|
||||
|
||||
class NoTracebackStreamHandler(logging.StreamHandler):
|
||||
def handle(self, record):
|
||||
info, cache = record.exc_info, record.exc_text
|
||||
record.exc_info, record.exc_text = None, None
|
||||
|
||||
if record.levelname == 'WARNING':
|
||||
color = colorama.Fore.YELLOW
|
||||
elif record.levelname in ['ERROR', 'EXCEPTION']:
|
||||
color = colorama.Fore.LIGHTRED_EX
|
||||
elif record.levelname == 'INFO':
|
||||
color = colorama.Fore.LIGHTBLUE_EX
|
||||
else:
|
||||
color = colorama.Fore.WHITE
|
||||
try:
|
||||
print(color, end='', flush=True)
|
||||
super().handle(record)
|
||||
finally:
|
||||
record.exc_info = info
|
||||
record.exc_text = cache
|
||||
print(colorama.Style.RESET_ALL, end='', flush=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue