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 🙏

© 2026 – Pkg Stats / Ryan Hefner

smartlog-mchapps

v0.0.3

Published

A WebSocket-based local logging client

Readme

smartlog-mchapps

A lightweight, robust WebSocket-based logging utility for Node.js.
It streams your structured logs in real-time to a local or remote WebSocket server, captures stack-trace caller insights, handles circular references safely, and queues your logs automatically if the network drops.


✨ Features

  • 🔌 Real-time WebSocket Streaming
    Instantly streams JSON payloads over WebSockets.

  • 📦 Smart Log Queueing
    If the log server/receiver goes offline, logs are buffered in memory and flushed automatically once reconnected.

  • 🔄 Auto-Reconnect
    Attempts to reconnect to your WebSocket host every 3 seconds if disconnected.

  • 📍 Automatic Source Tracing
    Extracts exact file, line number, and column number of the code calling the log.

  • 🛡️ Circular Dependency Safe
    Safe JSON stringification that intercepts circular object references and prevents application crashes.

  • 🪶 Zero Config Fallback
    Automatically falls back to standard console.log mirroring.


📦 Installation

Install the package via npm:

npm install smartlog-mchapps

🚀 Quick Start

1. Initialize and Use

import { Logger } from 'smartlog-mchapps';

// Connects to ws://localhost:9000 by default
const logger = new Logger();

// Simple Logging
logger.info('Application started successfully');

// Logging with Metadata / Context
logger.debug('User profile loaded', {
  userId: 42,
  role: 'admin'
});

// Safe from Circular References (won’t crash!)
const circularObj: any = {};
circularObj.self = circularObj;

logger.warn('Careful with this object', circularObj);

2. Custom Port Specification

If your WebSocket log server is running on a different port:

const logger = new Logger(8080);
// Connects to ws://localhost:8080

🧱 Structured Log Payload

Every log generated streams a highly structured JSON object.

Example:

logger.error('Database connection failed', { attempt: 3 });

Emits:

{
  "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "timestamp": 1715975847000,
  "level": "error",
  "message": "Database connection failed",
  "context": {
    "attempt": 3
  },
  "source": {
    "file": "/Users/username/repos/app/src/db.ts",
    "line": 14,
    "column": 12
  }
}

📚 API Reference

new Logger(port?: number)

Creates a new logger instance and immediately opens an asynchronous background WebSocket connection.

Parameters

| Parameter | Type | Default | Description | |---|---|---|---| | port | number | 9000 | Local WebSocket port |


🛠 Methods

All logging methods accept:

  • A descriptive message string
  • An optional context object containing arbitrary metadata

logger.info(message, context?)

Logs informational events.

logger.info('Server started');

logger.warn(message, context?)

Logs warning events.

logger.warn('Memory usage is high');

logger.error(message, context?)

Logs application errors.

logger.error('Database unavailable', {
  retries: 2
});

logger.debug(message, context?)

Logs debug-level diagnostics.

logger.debug('Cache miss', {
  key: 'user:42'
});

logger.log(level, message, context?)

Logs using a custom log level.

logger.log('critical', 'Payment gateway failure', {
  provider: 'Stripe'
});

✅ Why Use smartlog-mchapps?

  • Minimal setup
  • Developer-friendly structured logs
  • Reliable reconnect + buffering behavior
  • Safe serialization
  • Helpful source tracing for debugging
  • Works great for local development and distributed systems

📄 License

MIT