#logging #stderr #target #std #log-level #traits #edwardium

no-std edwardium_logger

Another simple logger implementation

7 releases (stable)

1.2.2 Jul 3, 2022
1.2.1 Aug 15, 2021
1.2.0 Jul 8, 2021
1.1.0 Mar 31, 2020
0.1.0 Jun 7, 2019

#15 in #stderr


Used in 3 crates

MIT/Apache

25KB
692 lines

Simple logger implementation that works using targets.

Instead of needing multiple logging crates to log to multiple targets this crate provides a layer of abstraction and a few default targets. A target has to implement the Target trait.

To start logging, create the Logger object either statically or dynamically and then call one of its init_ methods.

For example, for a dynamic logger (requires std feature):

use edwardium_logger::targets::stderr::StderrTarget;
let logger = edwardium_logger::Logger::new(
	StderrTarget::new(log::Level::Trace, Default::default()),
	std::time::Instant::now()
);
logger.init_boxed().expect("Could not initialize logger");

Logger can also be created and set statically, though this has a few caveats (read the documentation of Logger::new for more):

use edwardium_logger::{
	targets::{stderr::StderrTarget, util::ignore_list::IgnoreList},
	timing::DummyTiming
};
static LOGGER: edwardium_logger::Logger<(StderrTarget), DummyTiming> =
	edwardium_logger::Logger {
		targets: StderrTarget::new(log::Level::Trace, IgnoreList::EMPTY_PATTERNS),
		start: DummyTiming
	};
LOGGER.init_static();

Dependencies

~165KB