You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typer/Click invocation result doesn't capture stdout/stderr when using stdlib.LoggerFactory #686
I'm not sure if this is structlog or a click issue but trying here first.
For some reason, using stdlib.LoggerFactory prevents typer/click to capture stdout/stderr in the invocation result while a PrintLogger doesn't.
Here's a minimal example, any pointers to resolve/workaround this issue is most welcome.
# hello.pyimportstructlogimporttyperlogger=structlog.get_logger()
# swapping LoggerFactory for a PrintLogger makes the test passstructlog.configure(logger_factory=structlog.stdlib.LoggerFactory())
app=typer.Typer()
@app.command()defhello(name: str) ->None:
logger.info("Hello, %s!", name)
if__name__=="__main__":
app()
stdlib.LoggerFactory uses stdlib's logging for output, so you must look into the integration between click and logging. It is not in structlog's power to do anything about it once it's inside logging.
Right, I thought so. What’s confusing me is that stdlib logging works fine when structlog is not in the chain. I was thinking maybe there’s something that bothers it in the way stdlib logger is configured by structlog but it you don’t have any ideas what it could be I’ll try looking into click.
Activity
hynek commentedon Dec 18, 2024
stdlib.LoggerFactory uses stdlib's
loggingfor output, so you must look into the integration between click andlogging. It is not in structlog's power to do anything about it once it's insidelogging.ivasic commentedon Dec 18, 2024
Right, I thought so. What’s confusing me is that stdlib logging works fine when structlog is not in the chain. I was thinking maybe there’s something that bothers it in the way stdlib logger is configured by structlog but it you don’t have any ideas what it could be I’ll try looking into click.
Thanks for the response in any case!