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
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.
I'm not sure if this is
structlog
or aclick
issue but trying here first.For some reason, using
stdlib.LoggerFactory
prevents typer/click to capture stdout/stderr in the invocation result while aPrintLogger
doesn't.Here's a minimal example, any pointers to resolve/workaround this issue is most welcome.
a test case:
Running this test results in the assertion and
result.stdout
is completely empty.The text was updated successfully, but these errors were encountered: