mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-11-05 22:20:14 +08:00
Improve logging
This commit is contained in:
parent
fef08cbeae
commit
d26671e5f4
4 changed files with 7 additions and 7 deletions
|
|
@ -17,6 +17,6 @@ config
|
||||||
Dockerfile
|
Dockerfile
|
||||||
venv
|
venv
|
||||||
.idea
|
.idea
|
||||||
.env
|
.venv
|
||||||
test.py
|
test.py
|
||||||
!config/config.yml.sample
|
!config/config.yml.sample
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -8,4 +8,4 @@ __pycache__/
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.github/**
|
!.github/**
|
||||||
*.svg
|
*.svg
|
||||||
.env
|
.venv
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
2.2
|
2.3
|
||||||
|
|
@ -23,8 +23,8 @@ def print_multiline(lines, loglevel='INFO'):
|
||||||
if len(line) > 0 and i != len(line_list)-1:
|
if len(line) > 0 and i != len(line_list)-1:
|
||||||
logger.log(getattr(logging, loglevel),line)
|
logger.log(getattr(logging, loglevel),line)
|
||||||
if i == 0:
|
if i == 0:
|
||||||
logger.handlers[1].setFormatter(logging.Formatter(" " * 37 + "| %(message)s"))
|
logger.handlers[1].setFormatter(logging.Formatter(" " * 65 + "| %(message)s"))
|
||||||
logger.handlers[1].setFormatter(logging.Formatter("[%(asctime)s] %(levelname)-10s | %(message)s"))
|
logger.handlers[1].setFormatter(logging.Formatter("[%(asctime)s] %(filename)-27s %(levelname)-10s | %(message)s"))
|
||||||
|
|
||||||
def print_stacktrace():
|
def print_stacktrace():
|
||||||
print_multiline(traceback.format_exc())
|
print_multiline(traceback.format_exc())
|
||||||
|
|
@ -65,8 +65,8 @@ def separator(text=None, space=True, border=True, loglevel='INFO'):
|
||||||
def apply_formatter(handler, border=True):
|
def apply_formatter(handler, border=True):
|
||||||
text = f"| %(message)-{screen_width - 2}s |" if border else f"%(message)-{screen_width - 2}s"
|
text = f"| %(message)-{screen_width - 2}s |" if border else f"%(message)-{screen_width - 2}s"
|
||||||
if isinstance(handler, RotatingFileHandler):
|
if isinstance(handler, RotatingFileHandler):
|
||||||
#text = f"[%(asctime)s] %(filename)-27s %(levelname)-10s {text}"
|
text = f"[%(asctime)s] %(filename)-27s %(levelname)-10s {text}"
|
||||||
text = f"[%(asctime)s] %(levelname)-10s {text}"
|
#text = f"[%(asctime)s] %(levelname)-10s {text}"
|
||||||
handler.setFormatter(logging.Formatter(text))
|
handler.setFormatter(logging.Formatter(text))
|
||||||
|
|
||||||
def adjust_space(display_title):
|
def adjust_space(display_title):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue