| Crates.io | consola |
| lib.rs | consola |
| version | 0.0.0-alpha.0 |
| created_at | 2025-10-03 15:04:32.46816+00 |
| updated_at | 2025-10-03 15:04:32.46816+00 |
| description | π¨ Elegant Console Logger for Rust and Browser |
| homepage | |
| repository | https://github.com/MuntasirSZN/consola-rs |
| max_upload_size | |
| id | 1866806 |
| size | 290,791 |
Elegant Console Logger for Rust and Browser (WASM)
A Rust port of unjs/consola providing beautiful, powerful logging for native Rust applications and WebAssembly.
log and tracing crate supportAdd to your Cargo.toml:
[dependencies]
consola = "0.0.0-alpha.0"
[dependencies]
consola = { version = "0.0.0-alpha.0", features = ["color", "fancy", "json"] }
Available features:
color (default) - ANSI color support via anstreamfancy (default) - Fancy reporter with icons and enhanced formattingjson - JSON reporter for structured loggingprompt-demand - Interactive prompts using the demand crate (native only)wasm - WebAssembly support via wasm-bindgenbridge-log - Integration with the log cratebridge-tracing - Integration with the tracing crateuse consola::{info, warn, error, success};
fn main() {
info!("Application started");
success!("Database connected successfully");
warn!("Cache miss for key: {}", "user:123");
error!("Failed to process request");
}
use consola::{info, debug};
let username = "alice";
let count = 42;
info!("User {} logged in", username);
debug!("Processing {} items", count);
use consola::info_raw;
// Bypass formatting pipeline for maximum performance
info_raw!("This is a raw message");
use consola::log_type;
// Register and use custom log types
log_type!("custom", "Custom message: {}", value);
log and tracing integrationBuild for WASM:
# Install wasm-pack
cargo install wasm-pack
# Build for web target
wasm-pack build --target web --features wasm
Use in JavaScript:
import init, { info, warn, error } from './pkg/consola.js';
await init();
info("Hello from WASM!");
warn("This is a warning");
error("This is an error");
Note: Interactive prompts are not available in WASM - calling prompt methods will return an error.
Simple, clean output:
[info] Application started
[warn] Low disk space
[error] Connection failed
fancy feature)Enhanced output with icons and colors:
βΉ info Application started
β warn Low disk space
β error Connection failed
json feature)Structured JSON output for log aggregation:
{"time":"2024-01-01T00:00:00Z","level":4,"type":"info","message":"Application started"}
Automatically deduplicate repeated messages:
use consola::info;
// These will be coalesced into a single log with repetition count
for _ in 0..100 {
info!("Processing batch");
}
// Output: [info] Processing batch (x100)
Buffer logs and replay them:
// Pause logging
consola.pause();
info!("This will be buffered");
warn!("This too");
// Resume and flush all buffered logs
consola.resume();
Automatically format error source chains:
use consola::error;
use std::error::Error;
fn handle_error(err: Box<dyn Error>) {
error!("Operation failed: {}", err);
// Automatically shows full error chain with "Caused by:" sections
}
# Run all tests
cargo test --all-features
# Run with nextest (recommended)
cargo nextest run --all-features
# Run doctests
cargo test --doc
# Format code
cargo fmt --all
# Lint
cargo clippy --all-targets --all-features -- -D warnings
# Build
cargo build --all-features
# Run all checks
just check
consola-rs is designed for high performance:
smallvec for common casesSee BENCHMARKS.md for detailed performance characteristics.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License - see LICENSE file for details.
Status: Alpha - API may change. Not yet recommended for production use.