reorganization
- Had to reorganize so that Alembic's env.py could reference the tables in both local environment and a docker environment without manually modifying the python sys path. Maybe there is a better way idk
This commit is contained in:
parent
3670d1522f
commit
a101447eeb
22 changed files with 77 additions and 64 deletions
29
src/bot/log.py
Normal file
29
src/bot/log.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import logging
|
||||
import os
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
# log info level logs to stdout and debug to debug file
|
||||
|
||||
log_format = "%(levelname)s %(asctime)s - %(message)s"
|
||||
logging.basicConfig(
|
||||
handlers=[RotatingFileHandler(f"{os.getenv('BOT_CONFIG_DIR', './config')}/debug.log", maxBytes=500000, backupCount=10)],
|
||||
level=logging.DEBUG,
|
||||
format=log_format)
|
||||
|
||||
console_output = logging.StreamHandler()
|
||||
console_output.setLevel(logging.INFO)
|
||||
console_format = logging.Formatter(log_format)
|
||||
console_output.setFormatter(console_format)
|
||||
|
||||
info_log_file = RotatingFileHandler(f"{os.getenv('BOT_CONFIG_DIR', './config')}/info.log", maxBytes=100000, backupCount=10)
|
||||
info_log_file.setLevel(logging.INFO)
|
||||
info_log_format = logging.Formatter(log_format)
|
||||
info_log_file.setFormatter(info_log_format)
|
||||
|
||||
logging.root.addHandler(console_output)
|
||||
logging.root.addHandler(info_log_file)
|
||||
|
||||
|
||||
def get_logger(name):
|
||||
l = logging.getLogger(name)
|
||||
return l
|
Loading…
Add table
Add a link
Reference in a new issue