Optionally intercept standard Python logging and redirect to loguru handler#124
Optionally intercept standard Python logging and redirect to loguru handler#124
Conversation
📊 SonarQube Summary
|
🐳 Docker Image BuiltA new Docker image has been built for this PR: Image: Pull command: docker pull australia-southeast1-docker.pkg.dev/cpg-common/images-dev/cpg_flow:4a606000f80c33b96d551170127f6ff5e0cb1134🔗 View in Google Cloud Console This comment was automatically generated by the Docker workflow. |
dancoates
left a comment
There was a problem hiding this comment.
Looks good, a bit of a fiddly implementation but as per the docs you linked this does seem to be the advised way to have loguru intercept standard logging.
|
Indeed… You would think loguru could provide a suitable default InterceptHandler rather than inviting everyone to write it themselves… ETA: Requested three years ago: Delgan/loguru#633. |
|
Hey @jmarshall is this okay to merge still? |
…andler As per loguru documentation (see the "Entirely compatible with standard logging" section).
7fb3c6e to
4a60600
Compare
I still think it would be worth looking at whether there are standard-logging-using flow-based repos and if so what the effect of this on them is. But perhaps just merging this and crossing that bridge when we come to it suffices. |
|
I suppose the PR builds in enough ways to switch it off that we could just merge it and expect any flow-based repos for which it's a problem to turn it off, either in config or |
As per the loguru documentation.
See batch 631674 which ran on an image that includes this PR — note the log ends with log messages from modules within
/cpg-flow/.venv/lib/…whereas batch 631672 is of similar vintage but does not contain this PR and omits these log messages.Before merging this, we would need to consider whether we facilitate cpg-flow-using workflows that prefer standard logging rather than loguru, and what the desired behaviour there would be — perhaps to redirect cpg-flow's loguru messages to the standard logger instead.