prevent creating dupliacted log handler and remove unused

This commit is contained in:
hibobmaster 2023-04-17 21:20:13 +08:00
parent a96f40f7a2
commit 4c11286f95
Signed by: bobmaster
GPG key ID: 316B77D7914D713C
2 changed files with 24 additions and 27 deletions

5
log.py
View file

@ -2,9 +2,10 @@ import logging
def getlogger(): def getlogger():
# create a custom logger # create a custom logger if no log handler
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
if not logger.hasHandlers():
logger.setLevel(logging.INFO)
# create handlers # create handlers
warn_handler = logging.StreamHandler() warn_handler = logging.StreamHandler()
info_handler = logging.StreamHandler() info_handler = logging.StreamHandler()

View file

@ -1,8 +1,6 @@
import asyncio import asyncio
import json import json
import os import os
import signal
from functools import partial
from bot import Bot from bot import Bot
from log import getlogger from log import getlogger
@ -53,6 +51,4 @@ async def main():
if __name__ == "__main__": if __name__ == "__main__":
logger.info("matrix chatgpt bot start.....") logger.info("matrix chatgpt bot start.....")
print("matrix chatgpt bot start.....")
asyncio.run(main()) asyncio.run(main())