@emschwartz I don't think
#[cfg(feature = "tracing-log/std")]
is valid — I think if we want to have a feature gate for enabling the std
feature on tracing-log
, we need to add our own feature flag for it.
Or, I think, we should just always enable tracing-log/std
in the subscriber
crate's Cargo.toml
; the subscriber crate already requires the standard library and doesn't support no-std
currently. That's what I was trying to say in #400 (comment), but this may have not been clear, sorry!
@hawkw I tried to get the impl Error...
return type to work but haven't been able to figure out how.
tracing-subscriber
currently includes the std
feature for tracing-log
. However, changing this line to #[cfg(feature = "tracing-log")]
produces this error:
error[E0277]: `?` couldn't convert the error to `std::boxed::Box<tracing_core::dispatcher::SetGlobalDefaultError>`
--> tracing-subscriber/src/fmt/mod.rs:453:57
|
453 | tracing_log::LogTracer::init().map_err(Box::new)?;
| ^ the trait `std::convert::From<std::boxed::Box<log::SetLoggerError>>` is not implemented for `std::boxed::Box<tracing_core::dispatcher::SetGlobalDefaultError>`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the following implementations were found:
<std::boxed::Box<(dyn std::error::Error + 'a)> as std::convert::From<E>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<&str>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::borrow::Cow<'a, str>>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::string::String>>
and 16 others
= note: required by `std::convert::From::from`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `tracing-subscriber`.
To learn more, run the command again with --verbose.
I tried casting both to Box<Error>
s but then get errors saying that it can't be sent between threads or isn't sized.
If you know how to quickly solve this, feel free to edit the PR. I'm pretty stumped though so I'd opt to just use the enum.
@emschwartz I went ahead and fixed the boxed errors, I hope that's okay! I wanted to be able to go ahead and merge this so we can get a v0.1.6 release published.
28 | 28 | //! [ignore]: struct.Builder.html#method.ignore_crate | |
29 | 29 | use crate::{format_trace, AsTrace}; | |
30 | 30 | use log; | |
31 | pub use log::SetLoggerError; |
If the error is boxed, this type doesn't need to be made public
the errors in tracing-log
are not boxed (which was the case before, I think — I'm surprised that wasn't a problem in the past)
@hawkw Sounds good, thanks for doing that!
Login to write a write a comment.
🤦♂️
Motivation
I thought the boxing errors solution implemented in #400 was equivalent to the enum solution in emschwartz@f22bae5, but the current master doesn't actually work to install the global
LogTracer
.I can't figure out why the current cargo features don't end up turning on this line, but I confirmed with the log example in 4511325 that it's not currently working.
Solution
Using an enum for the two types of errors instead of boxing them solves the problem.