forked from sudoskys/TelegramBotTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (25 loc) · 744 Bytes
/
main.py
File metadata and controls
33 lines (25 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import asyncio
import sys
from dotenv import load_dotenv
from loguru import logger
from app.controller import BotRunner
from app_conf import settings
load_dotenv()
# 移除默认的日志处理器
logger.remove()
# 添加标准输出
print("从配置文件中读取到的DEBUG为", settings.app.debug)
handler_id = logger.add(sys.stderr, level="INFO" if not settings.app.debug else "DEBUG")
# 添加文件写出
logger.add(
sink="run.log",
format="{time} - {level} - {message}",
level="INFO",
rotation="100 MB",
enqueue=True,
)
logger.info("Log Is Secret, Please Don't Share It To Others")
async def main():
await asyncio.gather(BotRunner().run())
loop = asyncio.get_event_loop()
loop.run_until_complete(main())