From log and env_logger
You can keep every call site. Replace the logger set-up and rlg becomes the backend behind the log facade:
-env_logger::init();
+let _guard = rlg::init().unwrap();
Existing log::info! calls are then written through rlg. Their message text is kept as it is; to get typed attributes instead of values formatted into the message, rewrite a call to the fluent API:
-info!("user_id={user_id} authenticated");
+rlg::log::Log::info("authenticated").with("user_id", user_id).fire();
From tracing
Events map one to one; spans do not. rlg records flat events with attributes:
-tracing::info!(user_id = 42, region = "eu-west-1", "authenticated");
+rlg::log::Log::info("authenticated")
+ .with("user_id", 42_u64)
+ .with("region", "eu-west-1")
+ .fire();
If you rely on spans, #[instrument] or propagating span context between services, keep tracing. rlg::init() installs rlg as the tracing subscriber, and with the tracing-layer feature RlgLayer adds rlg to an existing subscriber stack, so tracing's events still reach rlg's formats, sinks and redaction.
From slog
There is no inherited context. slog's o!(...) key-value context has no direct equivalent: each rlg record is self-contained. Wrap the shared part in a function:
use Log;
service_log.with.fire;
slog-async's channel is not needed: rlg's engine already moves records off the calling thread.
Level mapping
| log, tracing, slog | rlg |
|---|---|
trace! | Log::trace |
debug! | Log::debug |
info! | Log::info |
warn! | Log::warn |
error! | Log::error |
slog's crit! | Log::critical |
rlg adds Log::verbose and Log::fatal.
From an older rlg
rlg is at 0.0.x, and breaking changes are marked Breaking in its CHANGELOG. Every crate in the workspace is released at the same version, so upgrade them together. Code written for 0.0.3, the version the old version of this site described, used Log::new(...) with positional arguments and an async log() call; today's API is the builder shown on the getting started page.
The full guides are in the user manual.