Open
Conversation
0209764 to
7e997df
Compare
7e997df to
3833ae9
Compare
Draft
|
🤖 SemverChecks 🤖 No breaking API changes detected Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered. |
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.
This PR implements
litebox_util_log, a logging facade that works with bothlogandtracing, allowing switching between the two backends. It learns a bunch of useful tricks from each of the two:litebox_util_log's syntax for the macros is closer to that oflog, in that you sayfoo:?rather than?foo(fromtracing). The former is nicer because it leads to better match towards Rust-y syntax.litebox_util_logenforces proper structured logging: here it improves upon bothlogandtracingby disallowing the formatting-based logging approach those allow (both of them support kv/structured logging, but they also allow format-based logging, which leads to harder-to-parse logs; we just disallow this footgun in our facade)litebox_util_logsupports spans, which exist intracingbut don't exist inlog. It emulates these by inserting span entry/exit events if using thelogbackend.litebox_util_logsupports#[instrument]on functions/methods.logdoes not have support for this at all, andtracing's support for it is with its own custom syntax that would not mesh well with ourlog-inspired syntax. So this attribute macro is custom and handles the nicer syntax consistently the way we'd like to have it.litebox_util_logsupports:err/:sval/... when using thelogbackend. These get flattened toDebugon thetracingbackend, becausetracingdoes not support these.The docs & tests demonstrate how to use these to add logging, but in short: add
debug!(foo, bar=5; "message")or similar.Note: this PR does not actually introduce any logging to any of the existing LiteBox crates, that will come in a separate PR. Currently, this is merely introducing the logging facade.