-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: create logging proxy #653
Merged
Merged
Conversation
This file contains 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
29b6c55
to
5316861
Compare
Very nice! Thanks, I'll take a closer look, but looks like a great refactor! |
e02d7bb
to
c0c882a
Compare
Wow nice you got it up! I'll review after I eat lunch. :) |
elcritch
suggested changes
Dec 18, 2023
808099f
to
ae9b0cb
Compare
@elcritch, thanks for the review! Apart from the question to @benbierens, all points have been addressed. Looking forward to your re-review 🙏 |
8c17fc8
to
437e793
Compare
elcritch
reviewed
Dec 19, 2023
elcritch
approved these changes
Dec 19, 2023
The logging proxy: - prevents the need to import chronicles (as well as export except toJson), - prevents the need to override `writeValue` or use or import nim-json-seralization elsewhere in the codebase, allowing for sole use of utils/json for de/serialization, - and handles json formatting correctly in chronicles json sinks
Not specifying a LogFormat will apply the formatting to both textlines and json sinks. Specifying a LogFormat will apply the formatting to only that sink.
We only need to import utils/json instead of std/json
Was causing unit tests to fail on Windows.
Windows was erroring with `could not load: pcre64.dll`. Instead of fixing that error, remove the pcre usage :)
Both json and textlines formatIt were not needed, and could be combined into one formatIt
debug output and logformat of json for integration test logs
8dd5b43
to
d60d0b4
Compare
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.
Add a logging proxy to achieve several goals:
--log-format=json
) which was effectively broken for many types.nim-json-serialization
from the codebasewriteValue
for new typestoJson
,%
,%*
to prevent conflictsWhen declaring a new type, one should consider importing the
codex/logutils
module, and specifyingformatIt
. If textlines log output and json log output need to be different, overloadformatIt
appropriately. If a json serialization is needed, it can be declared with a%
proc. Onlycodex/logutils
needs to be imported.With this PR in:
pkg/chronicles
, importpkg/codex/logutils
chronicles
is exported bylogutils
std/json
, importpkg/codex/utils/json
std/json
is exported byutils/json
which is exported bylogutils
pkg/nim-json-serialization
, importpkg/codex/utils/json
nim-json-serialization
In this case,
BlockAddress
is just an object, soutils/json
can handle serializing it without issue (only fields annotated with{.serialize.}
will serialize (opt-in).If one so wished, another option for the textlines log output, would be to simply
toString
the serialised json:In that case, both the textlines and json sinks would have the same output, so we could reduce this even further by not specifying a
LogFormat
:Note
Special thanks to @elcritch for the help on this one!