Closed breezewish closed 2 years ago
I believe this should be possible through the use of the FnValue
struct.
The following code should create a new child logger. The new child will have a thread_id key, computed by the "FnValue". The FnValue will debug-display the ThreadId
let child = parent.new(o!(
"thread_id" => slog::FnValue(|| {
format!("{:?}", std::thread::current().id())
})
));
// any use of the `child` logger will have `thread_id` as context.
play(&child);
You should also be able to modify this to work with the root loger (just move it to the initial o!()
instead of creating a new child).
Please let me know if this doesn't work
It would be great if the thread_id could be printed out, which could be helpful to learn the context in multi-threaded applications.