Skip to content

Commit 332af4b

Browse files
committed
runner: Add coloured logging
1 parent 7f5926c commit 332af4b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

runner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from obsbot import __version__, __codename__
99
from obsbot.main import OBSBot
1010

11+
RESET = "\x1b[0m"
12+
WARNING = "\x1b[33;20m%s" + RESET
13+
ERROR = "\x1b[31;20m%s" + RESET
14+
DEBUG = "\x1b[36;20m%s" + RESET
15+
1116
_log_dt_fmt = '%Y-%m-%d %H:%M:%S'
1217
_log_fmt = '[{asctime}] [{levelname}] {name}: {message}'
1318
logging.basicConfig(format=_log_fmt, datefmt=_log_dt_fmt, style='{', level=logging.INFO)
@@ -18,6 +23,9 @@
1823
def setup_logging(logfile=None, debug=False):
1924
try:
2025
max_bytes = 32 * 1024 * 1024 # 32 MiB
26+
logging.addLevelName(logging.WARNING, WARNING % logging.getLevelName(logging.WARNING))
27+
logging.addLevelName(logging.ERROR, ERROR % logging.getLevelName(logging.ERROR))
28+
logging.addLevelName(logging.DEBUG, DEBUG % logging.getLevelName(logging.DEBUG))
2129
logging.getLogger('discord').setLevel(logging.WARNING)
2230
logging.getLogger('discord.http').setLevel(logging.WARNING)
2331

0 commit comments

Comments
 (0)