Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PrefectFormatter to reduce logging configuration duplication #7588

Merged
merged 4 commits into from Nov 21, 2022

Conversation

zanieb
Copy link
Contributor

@zanieb zanieb commented Nov 18, 2022

Previously, flow run and task run loggers required their own formatters and did not propagate to the prefect logger. We did this to allow customization of formatting for flow and task run logs. However, this makes it difficult to change the behavior of Prefect's loggers since you need to adjust multiple handlers. We can accomplish this same feature with a single formatter that has support for flow and task run formats.

Example

Now, since there are not separate formatters for flow and task runs, you can change the format with a single setting e.g. to use JSON logging

PREFECT_LOGGING_HANDLERS_CONSOLE_FORMATTER="json" python example.py

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • This pull request includes tests or only affects documentation.
  • This pull request includes a label categorizing the change e.g. fix, feature, enhancement

Base automatically changed from update_json_logging_formatter to main November 18, 2022 16:58
@netlify
Copy link

netlify bot commented Nov 18, 2022

Deploy Preview for prefect-orion ready!

Name Link
🔨 Latest commit 37d747a
🔍 Latest deploy log https://app.netlify.com/sites/prefect-orion/deploys/637ba807afd21900099258dd
😎 Deploy Preview https://deploy-preview-7588--prefect-orion.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@zanieb zanieb added the enhancement An improvement of an existing feature label Nov 18, 2022
@zanieb zanieb requested a review from rpeden November 18, 2022 17:03
This is best-practice anyway now that formatting is sorted out
@zanieb zanieb marked this pull request as ready for review November 21, 2022 18:28
@rpeden
Copy link
Contributor

rpeden commented Nov 21, 2022

This looks great! I tried it and found:

  • Everything worked as expected on all Python versions we support.
  • A customized logging config based on an old version of logging.yml continued to work the way it worked before.

@peytonrunyan
Copy link
Contributor

It looks good to me, but I'm not as familiar with logging configuration. Got some reading pulled up for later.

@zanieb zanieb merged commit e7e93ed into main Nov 21, 2022
@zanieb zanieb deleted the simplify-logging-formats branch November 21, 2022 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants