🚑 修复致命日志加载错误 (#45)

* Update __init__.py
This commit is contained in:
Xtao_dada 2021-01-23 20:48:38 +08:00 committed by GitHub
parent 896ee59963
commit 6a18cef002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ from sys import version_info, platform
from yaml import load, FullLoader from yaml import load, FullLoader
from shutil import copyfile from shutil import copyfile
from redis import StrictRedis from redis import StrictRedis
from logging import getLogger, INFO, DEBUG, StreamHandler, basicConfig
from distutils2.util import strtobool from distutils2.util import strtobool
from coloredlogs import ColoredFormatter from coloredlogs import ColoredFormatter
from telethon import TelegramClient from telethon import TelegramClient
@ -17,6 +18,14 @@ working_dir = getcwd()
config = None config = None
help_messages = {} help_messages = {}
posthog.api_key = '1WepU-o7JwNKYqPNymWr_mrCu3RVPD-p28PUikPDfsI' posthog.api_key = '1WepU-o7JwNKYqPNymWr_mrCu3RVPD-p28PUikPDfsI'
logs = getLogger(__name__)
logging_format = "%(levelname)s [%(asctime)s] [%(name)s] %(message)s"
logging_handler = StreamHandler()
logging_handler.setFormatter(ColoredFormatter(logging_format))
logs.addHandler(logging_handler)
basicConfig(level=INFO)
getLogger('telethon').setLevel(INFO)
logs.setLevel(INFO)
try: try:
config = load(open(r"config.yml"), Loader=FullLoader) config = load(open(r"config.yml"), Loader=FullLoader)
@ -26,6 +35,12 @@ except FileNotFoundError:
exit(1) exit(1)
if strtobool(config['debug']):
logs.setLevel(DEBUG)
else:
logs.setLevel(INFO)
if platform == "linux" or platform == "linux2" or platform == "darwin" or platform == "freebsd7" \ if platform == "linux" or platform == "linux2" or platform == "darwin" or platform == "freebsd7" \
or platform == "freebsd8" or platform == "freebsdN" or platform == "openbsd6": or platform == "freebsd8" or platform == "freebsdN" or platform == "openbsd6":
logs.info( logs.info(