devela/sys/log/
namespace.rs
1use super::{LogLevelFilter, Logger, LoggerSetError};
4#[cfg(feature = "std")]
5use ::log::set_boxed_logger;
6#[cfg(all(not(feature = "safe_sys"), feature = "unsafe_thread"))]
7use ::log::set_logger_racy;
8use ::log::{logger, max_level, set_logger, set_max_level, STATIC_MAX_LEVEL};
9
10#[doc = crate::TAG_NAMESPACE!()]
11#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "dep_log")))]
15pub struct Log;
16
17impl Log {
18 pub const MAX_LEVEL: LogLevelFilter = STATIC_MAX_LEVEL;
24
25 #[rustfmt::skip]
29 pub fn max_level() -> LogLevelFilter { max_level() }
30
31 #[rustfmt::skip]
35 pub fn set_max_level(level: LogLevelFilter) { set_max_level(level) }
36
37 pub fn logger() -> &'static dyn Logger {
41 logger()
42 }
43
44 #[cfg(target_has_atomic = "ptr")]
48 #[cfg_attr(feature = "nightly_doc", doc(cfg(target_has_atomic = "ptr")))]
49 pub fn set_logger(logger: &'static dyn Logger) -> Result<(), LoggerSetError> {
50 set_logger(logger)
51 }
52
53 #[cfg(all(feature = "std", target_has_atomic = "ptr"))]
57 #[cfg_attr(feature = "nightly_doc", doc(cfg(all(feature = "std", target_has_atomic = "ptr"))))]
58 pub fn set_boxed_logger(logger: Box<dyn Logger>) -> Result<(), LoggerSetError> {
59 set_boxed_logger(logger)
60 }
61
62 #[cfg(all(not(feature = "safe_sys"), feature = "unsafe_thread"))]
69 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "unsafe_thread")))]
70 pub unsafe fn set_logger_racy(logger: &'static dyn Logger) -> Result<(), LoggerSetError> {
71 unsafe { set_logger_racy(logger) }
73 }
74
75 }