What is Smelt?
Smelt is the Rust equivalent of log from Charmbracelet. It provides gorgeous, human-readable logging with structured key-value pairs.
INFO Server started port=3000 env=production
WARN ⚠️ Disk space low available=10GB threshold=20GB
ERROR ❌ Connection failed host=db.example.com retries=3
Features
- 🎨 Colorful Output - Each log level has its own color
- 📝 Structured Logging - Add key-value pairs to any log
- ⏰ Timestamps - Optional, configurable timestamps
- 🎯 Log Levels - Debug, Info, Warn, Error, Fatal
- 🎭 Icons - Optional emoji icons for each level
- ⚙️ Customizable - Fully configurable styling
Installation
Quick Start
Simple Logging
use ;
info!;
warn!;
error!;
debug!;
With Key-Value Pairs
use ;
info!;
// INFO Request received method=GET path=/api/users
error!;
// ERROR Database error code=E001 table=users
Custom Logger
use ;
let logger = new
.with_timestamp
.with_icons
.min_level
.prefix;
logger.info;
// 14:30:45 ℹ️ INFO [myapp] Application started
logger.info_kv;
// 14:30:45 ℹ️ INFO [myapp] User login user=alice ip=192.168.1.1
Log Levels
| Level | Color | Icon | Use Case |
|---|---|---|---|
| DEBUG | Gray | 🔍 | Verbose debugging information |
| INFO | Blue | ℹ️ | General information |
| WARN | Amber | ⚠️ | Warnings that need attention |
| ERROR | Red | ❌ | Errors that need handling |
| FATAL | Dark Red | 💀 | Critical errors |
use Level;
let logger = new
.min_level; // Only show Warn and above
logger.debug; // Not shown
logger.info; // Not shown
logger.warn; // Shown
logger.error; // Shown
Styling Options
With Timestamps
let logger = new
.with_timestamp;
// 14:30:45 INFO Server started
With Icons
let logger = new
.with_icons;
// ℹ️ INFO Server started
// ⚠️ WARN Low memory
Short Level Names
use LogStyle;
let style = new
.short_level;
let logger = new
.style;
// INF Server started (instead of INFO)
Full Style
use LogStyle;
let style = full; // timestamps + icons
let logger = new
.style;
// 14:30:45 ℹ️ INFO Server started
Minimal Style
use LogStyle;
let style = minimal; // just the message
let logger = new
.style;
// Server started
Custom Colors
use LogStyle;
use Color;
let style = new
.key_color
.value_color;
let logger = new
.style;
Global Logger
For convenience, Smelt provides macros that use a global logger:
use ;
Ecosystem
Smelt is part of the Molten Labs open source ecosystem:
| Crate | Description |
|---|---|
| molten_brand | Design tokens & colors |
| glyphs | ANSI escape sequences |
| lacquer | Terminal styling |
| cauldron | TUI framework |
| sparks | TUI components |
| rune | Shell glamour |
| ember | Markdown renderer |
| smelt | Pretty logging (you are here) |
Why "Smelt"?
In a forge, to smelt is to extract pure metal from ore. Smelt extracts the essential information from your logs and presents it beautifully. ⚒️
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.