import logging
import logging.handlers
from collections.abc import Callable, Coroutine
from homeassistant.core import HomeAssistant as HomeAssistant, callback as callback, is_callback as is_callback
from typing import Any, TypeVar, TypeVarTuple, overload

_T = TypeVar('_T')
_Ts = TypeVarTuple('_Ts')

class HomeAssistantQueueHandler(logging.handlers.QueueHandler):
    listener: logging.handlers.QueueListener | None
    def prepare(self, record: logging.LogRecord) -> logging.LogRecord: ...
    def handle(self, record: logging.LogRecord) -> Any: ...
    def close(self) -> None: ...

def async_activate_log_queue_handler(hass: HomeAssistant) -> None: ...
def log_exception(format_err: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
async def _async_wrapper(async_func: Callable[[Unpack[_Ts]], Coroutine[Any, Any, None]], format_err: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
def _sync_wrapper(func: Callable[[Unpack[_Ts]], Any], format_err: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
def _callback_wrapper(func: Callable[[Unpack[_Ts]], Any], format_err: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
@overload
def catch_log_exception(func: Callable[[Unpack[_Ts]], Coroutine[Any, Any, Any]], format_err: Callable[[Unpack[_Ts]], Any]) -> Callable[[Unpack[_Ts]], Coroutine[Any, Any, None]]: ...
@overload
def catch_log_exception(func: Callable[[Unpack[_Ts]], Any], format_err: Callable[[Unpack[_Ts]], Any]) -> Callable[[Unpack[_Ts]], None] | Callable[[Unpack[_Ts]], Coroutine[Any, Any, None]]: ...
def catch_log_coro_exception(target: Coroutine[Any, Any, _T], format_err: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> Coroutine[Any, Any, _T | None]: ...
def async_create_catching_coro(target: Coroutine[Any, Any, _T]) -> Coroutine[Any, Any, _T | None]: ...
