Clean up useless logging handler setting (#120974)

Setting level of the handler does effectively nothing,
because HomeAssistantQueueHandler ignores this setting.
Also make the convention of getting the root logger uniform.
This commit is contained in:
Artur Pragacz 2024-08-05 11:22:13 +02:00 committed by GitHub
parent 3257bdeed2
commit 67e3139dcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -586,10 +586,10 @@ async def async_enable_logging(
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.WARNING)
sys.excepthook = lambda *args: logging.getLogger(None).exception(
sys.excepthook = lambda *args: logging.getLogger().exception(
"Uncaught exception", exc_info=args
)
threading.excepthook = lambda args: logging.getLogger(None).exception(
threading.excepthook = lambda args: logging.getLogger().exception(
"Uncaught thread exception",
exc_info=( # type: ignore[arg-type]
args.exc_type,
@ -616,10 +616,9 @@ async def async_enable_logging(
_create_log_file, err_log_path, log_rotate_days
)
err_handler.setLevel(logging.INFO if verbose else logging.WARNING)
err_handler.setFormatter(logging.Formatter(fmt, datefmt=FORMAT_DATETIME))
logger = logging.getLogger("")
logger = logging.getLogger()
logger.addHandler(err_handler)
logger.setLevel(logging.INFO if verbose else logging.WARNING)