Use tracing for logging.
#29
Merged
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.
Summary
This PR improves how logging is done in the differential testing framework adding more structured logs which allows us to quickly filter through logs and associate logs together.
Description
This PR replaces the
logcrate with thetracingcrate and replaces theenv_loggerwith thetracing-subscribercrate. This is done to allow us to get log messages with a lot more structured context that we can filter on.Why?
Reading the logs of any multi-threaded program is difficult as the logs from all threads all appear together in the same stream. In the case of this framework, this makes it hard to tell which metadata file is causing errors, and which specific test cases are causing errors.
Take the following as an example:
The above log message leaves us with many questions:
If we wanted to answer all of these questions with the
logcrate we would need to pass the entire execution context up the stack with each call that we make and we would need to keep re-logging this information in a consistent manner, which adds a lot of development and maintenance overhead.Using
tracingand and somespans(which I added in this PR) allows for more information to be added to logs which allows us to filter logs for specific metadata files and test cases a lot easier.The above log becomes the following:
We can see in this case that it's quite clear to us which metadata file encountered this error, it's the
era-compiler-tests/solidity/complex/defi/UniswapV4/test.jsonfile and the associated test cases.This allows for us to more easily filter for logs for a specific metadata file or for a specific case which we need at this stage in development to be able to quickly iterate, fix bugs, and get this framework to a production-level.
From a maintenance point of view, there's little maintenance overhead needed when using
tracingdue to their use ofspans and the span relationships which means that we do not need to pass the entire execution context up the stack just for logging, we get that for free (from a maintenance point of view) withtracingand a few well positionedspans.Note
This PR is not meant to fix all of the issues that we have around logging or improve all areas of the logging. Rather, it's meant to lay the foundation for everything else that's to come.