mirror of
https://gitee.com/openharmony/third_party_rust_log
synced 2024-11-27 01:40:27 +00:00
Implement Log for boxed data types that already implement the Log trait
This commit is contained in:
parent
b77ccefd7e
commit
b5e9d0182a
17
src/lib.rs
17
src/lib.rs
@ -1167,6 +1167,23 @@ impl Log for NopLogger {
|
||||
fn flush(&self) {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T> Log for std::boxed::Box<T>
|
||||
where
|
||||
T: ?Sized + Log,
|
||||
{
|
||||
fn enabled(&self, metadata: &Metadata) -> bool {
|
||||
self.as_ref().enabled(metadata)
|
||||
}
|
||||
|
||||
fn log(&self, record: &Record) {
|
||||
self.as_ref().log(record)
|
||||
}
|
||||
fn flush(&self) {
|
||||
self.as_ref().flush()
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the global maximum log level.
|
||||
///
|
||||
/// Generally, this should only be called by the active logging implementation.
|
||||
|
Loading…
Reference in New Issue
Block a user