molten_smelt 0.1.0

Beautiful, structured logging for the terminal ⚒️
Documentation
  • Coverage
  • 100%
    32 out of 32 items documented1 out of 2 items with examples
  • Size
  • Source code size: 39.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.79 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 20s Average build duration of successful builds.
  • all releases: 20s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chriscmathew-dorsia

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

cargo add smelt

Quick Start

Simple Logging

use smelt::{info, warn, error, debug};

info!("Server started");
warn!("Low disk space");
error!("Connection failed");
debug!("Processing request");

With Key-Value Pairs

use smelt::{info, error};

info!("Request received"; "method" => "GET", "path" => "/api/users");
// INFO Request received method=GET path=/api/users

error!("Database error"; "code" => "E001", "table" => "users");
// ERROR Database error code=E001 table=users

Custom Logger

use smelt::{Logger, Level};

let logger = Logger::new()
    .with_timestamp()
    .with_icons()
    .min_level(Level::Info)
    .prefix("myapp");

logger.info("Application started");
// 14:30:45 ℹ️  INFO [myapp] Application started

logger.info_kv("User login", &[
    ("user", &"alice"),
    ("ip", &"192.168.1.1"),
]);
// 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 smelt::Level;

let logger = Logger::new()
    .min_level(Level::Warn);  // Only show Warn and above

logger.debug("Skipped");  // Not shown
logger.info("Skipped");   // Not shown
logger.warn("Shown");     // Shown
logger.error("Shown");    // Shown

Styling Options

With Timestamps

let logger = Logger::new()
    .with_timestamp();

// 14:30:45 INFO Server started

With Icons

let logger = Logger::new()
    .with_icons();

// ℹ️  INFO Server started
// ⚠️  WARN Low memory

Short Level Names

use smelt::LogStyle;

let style = LogStyle::new()
    .short_level();

let logger = Logger::new()
    .style(style);

// INF Server started (instead of INFO)

Full Style

use smelt::LogStyle;

let style = LogStyle::full();  // timestamps + icons

let logger = Logger::new()
    .style(style);

// 14:30:45 ℹ️  INFO Server started

Minimal Style

use smelt::LogStyle;

let style = LogStyle::minimal();  // just the message

let logger = Logger::new()
    .style(style);

// Server started

Custom Colors

use smelt::LogStyle;
use glyphs::Color;

let style = LogStyle::new()
    .key_color(Color::from_hex("#F97316"))
    .value_color(Color::from_hex("#FAFAFA"));

let logger = Logger::new()
    .style(style);

Global Logger

For convenience, Smelt provides macros that use a global logger:

use smelt::{info, warn, error, debug, fatal};

fn main() {
    info!("Starting up");
    
    if let Err(e) = do_something() {
        error!("Operation failed"; "error" => e.to_string());
    }
}

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:

at your option.