use rlg::log::Log;
use rlg::log_format::LogFormat;
pub(crate) fn main() {
println!("๐ฆ RustLogs Macros Examples ๐ฆ\n");
fluent_api_example();
conditional_log_example();
rlg_span_example();
rlg_time_it_example();
rlg_mcp_notify_example();
unicode_log_example();
println!("\n๐ All examples completed successfully!");
}
fn fluent_api_example() {
println!("๐ฆ **Fluent API Example**");
println!("---------------------------------------------");
Log::info("This is an info message")
.component("component")
.time("2022-01-01T12:00:00Z")
.format(LogFormat::JSON)
.fire();
Log::warn("This is a warning").component("component").fire();
Log::error("This is an error").component("component").fire();
Log::trace("This is a trace").component("component").fire();
Log::fatal("This is fatal").component("component").fire();
}
fn conditional_log_example() {
println!("\n๐ฆ **Conditional Log Example**");
println!("---------------------------------------------");
let should_log = true;
if should_log {
Log::info("Conditional log fired")
.component("component")
.fire();
}
println!("(Log with true condition should have fired)");
let should_not_log = false;
if should_not_log {
Log::warn("This should not appear")
.component("component")
.fire();
}
println!("(Log with false condition should not have fired)");
}
fn rlg_span_example() {
println!("\n๐ฆ **rlg_span! Example**");
println!("---------------------------------------------");
let result = rlg::rlg_span!("Compute Task", {
let x = 10;
let y = 20;
x + y
});
println!(" Span result: {}", result);
}
fn rlg_time_it_example() {
println!("\n๐ฆ **rlg_time_it! Example**");
println!("---------------------------------------------");
let result = rlg::rlg_time_it!("Database Query", {
let x = 100;
x * 2
});
println!(" Timed result: {}", result);
}
fn rlg_mcp_notify_example() {
println!("\n๐ฆ **rlg_mcp_notify! Example**");
println!("---------------------------------------------");
rlg::rlg_mcp_notify!("user_status", "logged_in");
println!(" MCP notification sent");
}
fn unicode_log_example() {
println!("\n๐ฆ **Unicode Log Example**");
println!("---------------------------------------------");
Log::info("ใใใซใกใฏ RustLogs! ๐ฆ")
.component("component")
.time("2022-01-01T12:00:00Z")
.fire();
}