Closed najamelan closed 4 years ago
I missed the /* get the task id here */
part. Didn't realize that getting the task Id was not included in the crate.
@najamelan I started a patch to make it work out of the box in https://github.com/async-rs/async-log/pull/9, but never saw it through to completion. Still unsure if it's a good idea.
Looks like that is async-std specific? I found a solution that works for me with tracing-futures. The Instrumented
type wraps futures and executors to set the right span in the poll function. Thus it works even when using join
. Everything that runs concurrently can be detected in the logs, making it possible to create a gui that puts the log statements in columns side by side. Haven't made such a gui yet, but I will soon.
Oh, and as an added advantage, that allows you to set any structured data, like a name instead of a numeric task id, which is to be preferred I think.
Modifying the trace example like this:
I get the following output (as you can see, the task_id is always 0 for the relevant log messages, and log messages from async-std have task_id twice):