Using `std::panic::Location` in the `log` crate?

Now that #[track_caller] is stable, I went to one of our existing applications to see if I could fix the annoyance where our error reporting doesn't mix well with our retry mechanism because the retrier location gets into the error reports instead of the place where the actual error occurred. It didn't work out-of-the-box because log uses the file!() and line!() macros, which are built-in to the compiler and (at least from my observations) don't seem to use the same location information as std::panic::Location.

I'm wondering if this shouldn't be changed? It seems like you'd want the ability to manipulate location information in log messages for the same reasons you'd want to manipulate location information in panic messages. I'm more than happy to open a PR to log for this, but I wondered if I was missing a good reason to not do this

1 Like

Just as a note, I did get my issue resolved by generating my own log::Record values using the panic::Location information, my question is more about what the default should be.

I opened a PR for this, though I did put the functionality behind a feature so it wouldn't break if compiled with an old version of rustc:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.