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

Enable custom logging format #1582

Merged
merged 4 commits into from
Apr 25, 2024
Merged

Conversation

jagraff
Copy link
Contributor

@jagraff jagraff commented Apr 25, 2024

Summary

Enables custom flask log formatting. Added example omm_config with json formatting for reference

Test Plan

To test, replace
OMM_CONFIG: /build/reference_omm_configs/development_omm_config.py
with
OMM_CONFIG: /build/reference_omm_configs/json_log_omm_config.py
in docker-compose.yaml, then start the app. It should then log in json format after startup.

Copy link
Contributor

@Dcallies Dcallies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty clean as is, when we were chatting offline it seemed like it would be a lot more messy.


class CustomJsonFormatter(jsonlogger.JsonFormatter):
"""
Outputs logs in a JSON format.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could mention the framework this would be used with here to help folks figure out what it's used for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By framework, do you mean flask? Or the service that will be processing the logs that needs them in json format?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter :P

@Dcallies Dcallies merged commit 706388d into facebook:main Apr 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants