npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pino-rs

v0.3.13

Published

A blazingly fast Rust implementation of pino.js logger - fully compatible drop-in replacement

Readme

pino-rs

A blazingly fast Rust implementation of the pino.js logger. Built for performance while maintaining full API compatibility with pino.js, making it a true drop-in replacement.

Features

  • Extremely Fast: Written in Rust for maximum performance with minimal overhead
  • Drop-in Replacement: Compatible with pino.js API - works with existing code
  • JSON Structured Logging: Outputs structured JSON logs like pino.js
  • Child Loggers: Supports child loggers with inherited context
  • Multiple Log Levels: trace, debug, info, warn, error, fatal
  • Zero-Cost Abstractions: Leverages Rust's performance guarantees
  • Node.js Bindings: Use from JavaScript/TypeScript via NAPI bindings
  • Thread-Safe: Built on Rust's concurrency primitives

Performance

pino-rs is now FASTER than pino.js! 🚀

Benchmark Results (100K iterations, Apple Silicon)

| Test | pino.js | pino-rs | Performance | | -------------- | ------- | ----------- | ------------------- | | Simple logging | 1.64M/s | 3.57M/s | 2.18x faster 🚀 | | Child logger | 1.75M/s | 2.38M/s | 1.36x faster ✨ | | Mixed levels | 4.55M/s | 5.00M/s | 1.10x faster ✨ | | With fields | 1.23M/s | 735K/s | 0.60x | | Average | 2.29M/s | 2.92M/s | 1.28x faster ⚡ |

Performance Highlights

  • Simple logging: 2.18x faster (118% faster) than pino.js
  • Child loggers: 1.36x faster (36% faster) than pino.js
  • Mixed levels: 1.10x faster (10% faster) than pino.js
  • Overall: 1.28x faster (28% faster) average across all tests
  • ⚠️ With fields: Slower due to NAPI object conversion overhead

How We Achieved This

  1. Async Channel-Based Writes: Non-blocking logging with background writer thread
  2. Custom Fast JSON Serializer: Bypasses serde_json overhead, uses itoa and ryu for numbers
  3. 64KB Write Buffer: Batch writes reduce system calls
  4. Link-Time Optimization: Aggressive compiler optimizations with LTO
  5. Zero-Copy Strings: Arc for hostname, no unnecessary cloning
  6. Lock-Free Architecture: crossbeam channels for thread-safe async logging

For Pure Rust Usage

When used directly in Rust applications (no NAPI overhead), pino-rs is even faster. The NAPI bindings add overhead for JS ↔ Rust boundary crossings, but we've optimized to minimize this impact.

Installation

From NPM (Node.js)

npm install pino-rs

From Cargo (Rust)

[dependencies]
pino-core = "0.1"

Usage

Node.js / JavaScript

const pino = require("pino-rs");

// Basic usage
const logger = pino();
logger.info("hello world");
// {"level":30,"time":1531171074631,"msg":"hello world","pid":657,"hostname":"..."}

// With log level
const logger = pino({ level: "debug" });
logger.debug("debug message");

// With base fields
const logger = pino({
  base: {
    app: "my-app",
    version: "1.0.0",
  },
});
logger.info("application started");

// Child logger
const child = logger.child({ module: "auth" });
child.info("user logged in");

// With additional fields
logger.info({ userId: 42 }, "user action");

Rust

use pino_core::{Logger, LoggerBuilder, Level};
use serde_json::json;
use std::collections::HashMap;

fn main() {
    // Basic logger
    let logger = Logger::new();
    logger.info("Hello from pino-rs!");

    // With custom level
    let debug_logger = LoggerBuilder::new()
        .level(Level::Debug)
        .build();
    debug_logger.debug("Debug message");

    // With base fields
    let app_logger = LoggerBuilder::new()
        .with_field("app", "my-app")
        .with_field("version", "1.0.0")
        .build();
    app_logger.info("Application started");

    // Child logger
    let mut child_fields = HashMap::new();
    child_fields.insert("module".to_string(), json!("auth"));
    let child = app_logger.child(child_fields);
    child.info("User authenticated");
}

API Compatibility

Pino-rs implements the core pino.js API:

Logger Methods

  • trace(msg) - Log at trace level (10)
  • debug(msg) - Log at debug level (20)
  • info(msg) - Log at info level (30)
  • warn(msg) - Log at warn level (40)
  • error(msg) - Log at error level (50)
  • fatal(msg) - Log at fatal level (60)
  • child(bindings) - Create a child logger with additional context

Logger Options

  • level - Minimum log level (trace, debug, info, warn, error, fatal)
  • base - Base fields to include in all logs

Output Format

Pino-rs produces the same JSON output format as pino.js:

{
  "level": 30,
  "time": 1531171074631,
  "pid": 657,
  "hostname": "server-01",
  "msg": "hello world"
}

Project Structure

  • pino-core - Core Rust logging library
  • pino-node - Node.js bindings via NAPI
  • src/main.rs - Example Rust usage

Development

Build from source

# Clone the repository
git clone https://github.com/yourusername/pino-rs
cd pino-rs

# Build the Rust library
cargo build --release

# Build Node.js bindings
cd pino-node
npm install
npm run build

Run tests

# Rust tests
cargo test

# Node.js tests
cd pino-node
npm test

Run examples

# Rust example
cargo run

# Node.js example
cd pino-node
node test.js

Benchmarks

Memory Usage & Performance Comparison

Benchmark setup: 100,000 log iterations with object fields { a: 1, b: "test", c: i }

| Metric | pino.js | pino-rs | Improvement | | ------------------ | -------- | ------- | ---------------------- | | Execution Time | 1.92s | 1.66s | 13.5% faster ⚡ | | RSS Memory | 112.6 MB | 45.3 MB | 60% less memory 💾 | | Peak Memory | 91.6 MB | 17.9 MB | 80% less memory 🚀 |

Key Findings:

  • Faster execution: 1.66s vs 1.92s (13.5% improvement)
  • Significantly lower memory footprint: Uses 60-80% less memory
  • Better resource efficiency: Lower RSS and peak memory usage

Benchmark command:

/usr/bin/time -l node bench-pino-rs.js

Roadmap

  • [x] Core logging functionality
  • [x] JSON serialization
  • [x] Child loggers
  • [x] Node.js bindings
  • [ ] Transport system
  • [ ] Redaction support
  • [ ] Pretty printing
  • [ ] Comprehensive benchmarks
  • [ ] Full pino.js feature parity

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Credits

Inspired by and compatible with pino.js by Matteo Collina and the pino team.