| Crates.io | fake-log |
| lib.rs | fake-log |
| version | 0.1.0 |
| created_at | 2025-06-05 06:08:44.624297+00 |
| updated_at | 2025-06-05 06:08:44.624297+00 |
| description | A fake logging implementation with the same interface as log crate but with no-op implementation for embedded scenarios |
| homepage | https://github.com/fslongjin/fake-log |
| repository | https://github.com/fslongjin/fake-log |
| max_upload_size | |
| id | 1701117 |
| size | 32,342 |
A fake logging library that provides the same interface as Rust's log crate but with no-op implementations. Designed specifically for embedded scenarios where reducing memory footprint is critical.
log crateno_std environments with minimal dependenciesAdd to your Cargo.toml:
[dependencies]
fake-log = "0.1"
If your project already uses the log crate, you can quickly replace it:
[dependencies]
# log = "0.4" # Comment out the original log dependency
fake-log = { version = "0.1", package = "log" } # Use fake-log as replacement
Your existing code requires no changes.
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");
}
| Feature | log crate | fake-log |
|---|---|---|
| Runtime overhead | Small overhead | Zero overhead |
| Memory allocation | May allocate | Zero allocation |
| Binary size | Slightly larger | Minimal |
| Configuration complexity | Requires Logger setup | No configuration needed |
| Embedded support | Good | Excellent |
See complete examples in the examples/ directory:
cargo run --example basic
cargo run --example no_std
cargo run --example custom_logger
fake-log fully supports no_std environments:
#![no_std]
use fake_log::{info, error};
fn embedded_function() {
info!("Running in no_std environment");
error!("Error handling");
}
fake-log should perform best in all scenarios since it does nothing.
This project is licensed under MIT OR Apache-2.0, consistent with the Rust ecosystem.
Issues and pull requests are welcome!
Q: Why do I need fake-log? A: In embedded systems, even the lightest logging libraries can consume precious stack memory resources. fake-log provides a completely zero-overhead solution.
Q: Can I switch to real logging at runtime? A: No. fake-log is designed for compile-time optimization, and all log calls are removed at compile time.
Q: How can I use real logging during development and fake-log in production? A: You can use Cargo features and conditional compilation to achieve this switching.