[Python] Wrap "py.warnings" logger with structlog to add processors

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have a custom logger including processors, handlers etc. . I would like to wrap the "py.warnings" logger which I understand is used by the warnings so that my processors are 'injected'. However, running the following code does not change anything to the warning that is printed to the console.


    import logging
    import structlog
    import warnings

    structlog.wrap_logger(
    logging.getLogger("py.warnings"),
    # processors etc. ...
    )

    warnings.warn("abc")

    Continue reading...

Compartilhe esta Página