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 log level to workflow outputs #24

Merged
merged 1 commit into from
Feb 26, 2025
Merged

Add log level to workflow outputs #24

merged 1 commit into from
Feb 26, 2025

Conversation

lispandfound
Copy link
Contributor

@lispandfound lispandfound commented Feb 25, 2025

Small PR to add log levels to outputs of workflow stages. Essentially turning outputs from check-srf from

{"function": "check_srf", "id": "10f7fb13-02f2-481a-b671-19cc9462dce0", "realisation_ffp": "PosixPath('Darfield_Elliot_2012_Multi.json')", "srf_ffp": "PosixPath('test.srf')", "event": "called", "timestamp": "2025-02-25T03:02:39.595013Z"}
{"expected": 7.099999999999998, "actual": 7.100000006188335, "event": "SRF Magnitude", "timestamp": "2025-02-25T03:02:39.664837Z"}
{"function": "check_srf", "id": "10f7fb13-02f2-481a-b671-19cc9462dce0", "result": null, "event": "completed", "timestamp": "2025-02-25T03:02:39.665147Z"}

to outputs like

{"function": "check_srf", "id": "f26e16ec-a91a-4c79-be98-064b1c31444f", "realisation_ffp": "PosixPath('Darfield_Elliot_2012_Multi.json')", "srf_ffp": "PosixPath('test.srf')", "event": "called", "timestamp": "2025-02-25T03:16:16.286589Z", "level": "info"}
{"expected": 7.099999999999998, "actual": 7.100000006188335, "event": "SRF Magnitude", "timestamp": "2025-02-25T03:16:16.356692Z", "level": "info"}
{"function": "check_srf", "id": "f26e16ec-a91a-4c79-be98-064b1c31444f", "result": null, "event": "completed", "timestamp": "2025-02-25T03:16:16.357013Z", "level": "info"}

Note the addition of the level key to log outputs. The change is small but it means that tools like fblog that consume JSON logs can use the level for formatting and filtering.

Copy link
Member

@sungeunbae sungeunbae left a comment

Choose a reason for hiding this comment

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

I will find it more useful if the level appears the first, but I wonder if it is possible to do so in the dictionary?

@lispandfound
Copy link
Contributor Author

@sungeunbae I have no idea how to do that. I suspect structlog doesn't support this. However, I also don't think you need it because you aren't supposed to read these as plain text. Rather, you should pass these to other tools that understand json log formats. Here is an example of what I get when I pass the last log into fblog (a JSON CLI log viewer).

image

The idea of json formatted logs is a format-neutral logging style that can be ingested by other tools and formatted however you want. Thus, I doubt that structlog has any means to change the order of logged output in json format.

@lispandfound lispandfound merged commit 766ea8f into pegasus Feb 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants