style: 优化日志输出,方便排查问题

This commit is contained in:
涵曦 2024-07-28 08:09:34 +00:00
parent 43886116c1
commit 49f727477e
2 changed files with 7 additions and 1 deletions

View File

@ -84,7 +84,7 @@ def main():
"format": f"%(asctime)s [{__version__}] [%(levelname)s] %(filename)s:%(lineno)d: %(message)s", "format": f"%(asctime)s [{__version__}] [%(levelname)s] %(filename)s:%(lineno)d: %(message)s",
"datefmt": "[%X]", "datefmt": "[%X]",
} }
LOGGING_CONFIG["handlers"]["access"] = { LOGGING_CONFIG["handlers"]["access_file"] = {
"level": "INFO", "level": "INFO",
"class": "logging.handlers.RotatingFileHandler", "class": "logging.handlers.RotatingFileHandler",
"formatter": "access", "formatter": "access",
@ -92,6 +92,11 @@ def main():
"maxBytes": 10 * 1024 * 1024, "maxBytes": 10 * 1024 * 1024,
"backupCount": 1, "backupCount": 1,
} }
LOGGING_CONFIG["handlers"]["access_console"] = {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "access",
}
uvicorn.run( uvicorn.run(
HttpApp, HttpApp,
host=["::", "0.0.0.0"], host=["::", "0.0.0.0"],

View File

@ -1142,6 +1142,7 @@ class XiaoMusicDevice:
async def _do_next(): async def _do_next():
await asyncio.sleep(self._timeout) await asyncio.sleep(self._timeout)
try: try:
self.log.info("定时器时间到了")
await self.play_next() await self.play_next()
except Exception as e: except Exception as e:
self.log.error(f"Execption {e}") self.log.error(f"Execption {e}")