### Running All fake-log Examples (Bash) Source: https://github.com/fslongjin/fake-log/blob/master/examples/README.md Provides a consolidated command to execute multiple fake-log examples simultaneously. This allows for quick verification of various library features and behaviors in one go. ```Bash cargo run --example basic cargo run --example custom_logger cargo run --example compatibility cargo run --example benchmark --release ``` -------------------------------- ### Running fake-log Examples with Cargo Source: https://github.com/fslongjin/fake-log/blob/master/README.md These Bash commands demonstrate how to run the provided examples for the `fake-log` library using `cargo run --example`. This allows users to explore different usage scenarios, including basic logging, `no_std` environments, and custom logger implementations. ```Bash cargo run --example basic cargo run --example no_std cargo run --example custom_logger ``` -------------------------------- ### Basic Usage with fake-log (Rust/Bash) Source: https://github.com/fslongjin/fake-log/blob/master/examples/README.md Demonstrates fundamental usage of fake-log macros (error!, warn!, info!, debug!, trace!) including formatted and target-specific logging. It shows how these calls are silently ignored, with only `println!` statements producing output. ```Bash cargo run --example basic ``` -------------------------------- ### no_std Support with fake-log (Rust/Bash) Source: https://github.com/fslongjin/fake-log/blob/master/examples/README.md Illustrates using fake-log in `no_std` environments, including the `#![no_std]` attribute and custom panic handlers. It demonstrates how log calls are optimized away in embedded-like scenarios. ```Bash cargo run --example no_std ``` -------------------------------- ### Installing fake-log in Cargo.toml Source: https://github.com/fslongjin/fake-log/blob/master/README.md This TOML snippet shows how to add `fake-log` as a dependency to your Rust project's `Cargo.toml` file. This is the standard way to include the library for basic usage. ```TOML [dependencies] fake-log = "0.1" ``` -------------------------------- ### Custom Logger Implementation with fake-log (Rust/Bash) Source: https://github.com/fslongjin/fake-log/blob/master/examples/README.md Shows how to implement the `Log` trait with fake-log, including `Custom Logger` struct, `enabled`, `log`, and `flush` methods. It highlights manual record creation and logging for demonstration purposes, while macros are optimized away. ```Bash cargo run --example custom_logger ``` -------------------------------- ### API Compatibility with Standard Log Crate (Rust/Bash) Source: https://github.com/fslongjin/fake-log/blob/master/examples/README.md Demonstrates complete API compatibility with the standard `log` crate, including `Level`, `LevelFilter`, `Logger` management, `Metadata`, `Record` builders, and `log_enabled!` macro. It confirms API parity where logging operations return expected values but produce no output. ```Bash cargo run --example compatibility ``` -------------------------------- ### Performance Benchmark of fake-log Operations (Rust/Bash) Source: https://github.com/fslongjin/fake-log/blob/master/examples/README.md Measures the performance impact of fake-log operations, including simple, formatted, and conditional logging. It demonstrates the library's zero-overhead abstraction by showing extremely low execution times in release mode. ```Bash cargo run --example benchmark --release ``` -------------------------------- ### Replacing log Crate with fake-log in Cargo.toml Source: https://github.com/fslongjin/fake-log/blob/master/README.md This TOML configuration demonstrates how to replace the standard `log` crate with `fake-log` in your `Cargo.toml`. By specifying `package = "log"`, `fake-log` acts as a drop-in replacement, allowing existing code using `log` macros to function without modification, but with zero runtime overhead. ```TOML [dependencies] # log = "0.4" # Comment out the original log dependency fake-log = { version = "0.1", package = "log" } # Use fake-log as replacement ``` -------------------------------- ### Direct Usage of fake-log Macros in Rust Source: https://github.com/fslongjin/fake-log/blob/master/README.md This Rust snippet illustrates direct usage of `fake-log` by aliasing it as `log`. It shows various logging macros (`info!`, `debug!`, `error!`, `warn!`, `trace!`) and demonstrates support for the `target` parameter. All these calls are compile-time no-ops, producing no output and consuming no memory at runtime. ```Rust extern crate fake_log as log; fn main() { // These calls produce no output and allocate no memory log::info!("Application started"); log::debug!("Debug info: {}", 42); log::error!("Error message"); log::warn!("Warning message"); log::trace!("Trace message"); // Support for target parameter log::info!(target: "my_module", "Module-specific log"); } ``` -------------------------------- ### Using fake-log in no_std Environments (Rust) Source: https://github.com/fslongjin/fake-log/blob/master/README.md This Rust snippet showcases `fake-log`'s compatibility with `no_std` environments. By adding `#![no_std]` and importing specific macros, developers can use `info!` and `error!` within embedded functions without requiring the standard library, ensuring minimal resource consumption. ```Rust #![no_std] use fake_log::{info, error}; fn embedded_function() { info!("Running in no_std environment"); error!("Error handling"); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.