Repository navigation
PoC for Structured Debug Logging - #384
Merged
Merged
Conversation
This allows us to make ctx also structured and not crash on non-serializable outputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Sometimes it is quite hard to know what exactly is going on during the execution of a Xircuits file.
This implements a proof of concept for a structured debug logger. It outputs its log in a json lines format that is readable by json log tools like fblog.
For example:

The execution of a simple xircuits file like this produces the following output:
And a tool like fblog turns this into:

This implementation has a couple caveats:
The context is always areprof the context, as it may contain non-serializable objectsIf a component outputs non-serializable objects, the debug logging will crash.There are two environment variables to enable and configure debug logging:
XIRCUITS_DEBUG=trueenables the debug logging. In that case it will simply write tostderrXIRCUITS_DEBUG_FILE=<path>selects where the debug log should be written to.Pull Request Type
Type of Change
Tests
Logging to stderr
Create a xircuits file and run it with
XIRCUITS_DEBUG=trueset. You'll see debugging output right on the terminal.Logging to a File
Create a xircuits file and run it with
XIRCUITS_DEBUG=trueandXIRCUITS_DEBUG_FILE=debug.jsonlset. You'll see no debug output on the terminal, instead a file is created and you can find the debug output there.Tested on?