Macro slog_extlog::impl_value_wrapper [−][src]
Generate a slog::Value
trait implementation for a type we don’t
own but which implements std::fmt::Display
or std::fmt::Debug
.
This allows using types from third-party crates as values in external logs. The macro defines
a new wrapper type to be used in external logs, which does implement slog::Value
.
For example, if you want to use the (fictional) foo
crate and log errors from it, then write:
ⓘ
slog_extlog::impl_value_wrapper!(FooError, foo::Error);
Then anywhere you want to log a foo::Error
, you can instead use FooError(foo::Error)
- the
logged value will use foo:Error
’s impl of Display
.
For a type which implements Debug
but not Display
, then you can use a ?
character:
ⓘ
slog_extlog::impl_value_wrapper!(FooInternal, ?foo::InternalType);
Note: this macro can be deprecated once default impl
is available and
this issue is fixed.