-
Notifications
You must be signed in to change notification settings - Fork 422
Logging and spans via thread-local storage #4223
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
base: main
Are you sure you want to change the base?
Conversation
|
👋 Hi! I see this is a draft PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4223 +/- ##
=======================================
Coverage 89.33% 89.34%
=======================================
Files 180 180
Lines 139042 139082 +40
Branches 139042 139082 +40
=======================================
+ Hits 124219 124264 +45
+ Misses 12196 12193 -3
+ Partials 2627 2625 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I played with this a bit, sadly Rust doesn't allow you to convert an arbitrary (
(of course the [1] https://git.bitcoin.ninja/?p=rust-lightning;a=shortlog;h=refs/heads/claude/2025-11-dyn-logger [2] |
|
I've tried to make it work on top of your First I thought you wanted to bound everything on Proc macro for logger scope is interesting, and can indeed be extended with a node id in testing. |
|
The type passed to |
a64e87d to
ddf5cb4
Compare
|
I had tried that, but it didn't work. Same sized error. Pushed the commit. Maybe I am doing something wrong. |
|
I am wondering what the performance implications are of the logger scope. Just adding a node id in TLS would test-only, but storing the logger instance itself is production code that wouldn't be running if there was a global logger instead. |
|
I don't think its going to be material in either direct. Storing a |
Right, looks like claude just forgot to update the |
|
Oh, claude didn't update any of the references to dyn lol. Dumb LLMs just ignore half of what you tell them, I hadn't bothered to look at what it did, either. Anyway, gotta update all those bounds! |
|
With bound I started a bit of creative search/replace across the repo to do a sweeping conversion (https://github.com/lightningdevkit/rust-lightning/compare/main...joostjager:rust-lightning:dyn-logger?expand=0). Needs a bit more work. It's probably not necessary for deciding on the direction we want to take this to. |
ee40265 to
d3f7e4d
Compare
Reduce boiler plate for logging, and allow quick insertion of log statements anywhere without first threading through a logger instance and associated type parameter.
d3f7e4d to
a09f17d
Compare
Demonstrating how the proc macro can be used to set a thread-local logger at a public entry point. The scope name is also picked up and logged via log statements that still have an explicit logger instance.
a09f17d to
7dd7d6f
Compare
This PR adds the ability to open a logger scope that stores the
Loggerinstance in thread-local storage. This avoids the need to thread through a logger and associated type parameter to every method that needs to log.A logger scope can also be given a name and logging
Records now contain the names of the surrounding scopes.Example log output: