| Crates.io | cand |
| lib.rs | cand |
| version | 0.2.1 |
| created_at | 2025-07-26 20:37:32.918823+00 |
| updated_at | 2025-08-25 13:18:34.675227+00 |
| description | Beautiful embedded-first Rust logging library for ESP32 to servers with colorful output and zero-panic design. |
| homepage | |
| repository | https://github.com/CosmoBunny/cand.git |
| max_upload_size | |
| id | 1769447 |
| size | 348,780 |
Beautiful embedded-first Rust logging library for ESP32 to servers with colorful output and zero-panic design.
| Feature | Benefit | Use Case |
|---|---|---|
| ๐จ Smart Colors | Spot issues instantly | logger.log_err("โ Clear visibility") |
| โก no_std Ready | Runs everywhere | ESP32, STM32, WASM, bare metal |
| ๐ก๏ธ Never Panic | Production safe | try_run() and try_get() handles all errors gracefully |
| ๐ Pluggable | Your infrastructure | Files, UART, RTT, databases, networks |
| ๐ฆ Tiny Binary | <1KB overhead | Perfect for memory-constrained devices |
| ๐ฏ 2-Line Setup | Start in seconds | Works out of the box |
[dependencies]
cand = "0.2.1"
use cand::Logger;
use std::time::Instant;
fn main() {
let mut logger = Logger(Instant::now(), ());
logger.log_ok("๐ Server started successfully!");
logger.log_info("๐ก Listening on port 8080");
logger.log_warn("โ ๏ธ High memory usage: 87%");
logger.log_err("โ Database connection failed");
}
[dependencies]
cand = { version = "0.2.1", default-feature=false, features=["colors"] }
CAND automatically color-codes your logs for instant visual feedback:
log_ok() - Success operations (green)log_info() - Informational messages (blue)log_warn() - Warnings that need attention (yellow)log_err() - Critical errors (red)
use cand::Logger;
fn risky_operation() -> Result<String, &'static str> {
Err("network timeout")
}
fn fallback_handler(mut logger: Logger<std::time::Instant, ()>) {
logger.log_warn("๐ Entering fallback mode");
logger.log_info("๐พ Switching to cached data");
}
fn main() {
let logger = Logger(std::time::Instant::now(), ());
// Automatic error logging and graceful recovery
let (data, recovered_logger) = logger.try_get(
risky_operation(),
fallback_handler
);
}
struct UartStorage{
// Serial can be from any mcu serial
serial: Serial
};
impl StorageProvider for UartStorage {
fn write_data(&mut self, d: impl ufmt::uDebug) {
// Write to UART, RTT, or any embedded output
ufmt::uwrite!(self.serial,"{:?}", d);
}
}
| Feature | Description | Default |
|---|---|---|
std |
Standard library support, enables Instant time provider |
โ |
colors |
ANSI color output for beautiful terminal logs | โ |
ufmt |
Embedded-friendly formatting with zero allocations | No |
ufmt feature// Make sure Type should TimeProvider or StorageProvider
// Main logger with time and storage providers
pub struct Logger<T: TimeProvider, S: StorageProvider>(pub T, pub S);
Check out the examples directory:
basic_error_handling - Error recovery patternssample - Feature showcase and demobenchmark - Benchmark of 1_000_000 logs printRun examples:
cargo run --example sample
This project is licensed under the MIT License - see the LICENSE file for details.