Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

1.0 KB
Raw Blame
import logging
from collections.abc import Callable
from typing import Final


APPRISE_DIAGNOSTIC: Final = (
    "Apprise emitted a diagnostic; details suppressed to protect "
    "notification credentials."
)


class _AppriseSanitizingRecordFactory[**P]:
    def __init__(self, delegate: Callable[P, logging.LogRecord]) -> None:
        self._delegate = delegate

    def __call__(self, *args: P.args, **kwargs: P.kwargs) -> logging.LogRecord:
        record = self._delegate(*args, **kwargs)
        if record.name == "apprise" or record.name.startswith("apprise."):
            record.msg = APPRISE_DIAGNOSTIC
            record.args = ()
            record.exc_info = None
            record.exc_text = None
            record.stack_info = None
        return record


def install_apprise_log_record_factory() -> None:
    current_factory = logging.getLogRecordFactory()
    if isinstance(current_factory, _AppriseSanitizingRecordFactory):
        return
    logging.setLogRecordFactory(
        _AppriseSanitizingRecordFactory(current_factory)
    )