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

@khalidsheet/remote-logger-client

v1.1.0

Published

A client for the remote logger server

Readme

Remote Logger Client

A lightweight WebSocket client for sending logs to a remote logger server. Perfect for debugging frontend applications, mobile apps, or any JavaScript application where you need real-time log aggregation.

Note: This client requires the remote-logger-server to be running. This is a development tool intended for logging and debugging purposes.

Features

  • 🔄 Auto-reconnect - Automatically reconnects if the connection is lost (3-second retry)
  • 📍 Caller tracking - Automatically captures file, line, and column information
  • 🛡️ Fallback behavior - Falls back to console.log when disconnected
  • 🚀 Simple API - Easy-to-use interface with method chaining
  • 🎯 Multi-app support - Tag logs with application names for better organization
  • 📦 Zero configuration - Works out of the box with sensible defaults

Installation

npm install @khalidsheet/remote-logger-client
# or
pnpm add @khalidsheet/remote-logger-client
# or
yarn add @khalidsheet/remote-logger-client

Prerequisites

Make sure you have the remote logger server running:

npm install -g remote-logger-server
remote-logger-server

The server will start on port 4455 by default.

Usage

Basic Usage

import { createLogger } from "@khalidsheet/remote-logger-client";

const logger = createLogger("MyApp");

logger.log("Hello, world!");
logger.log("User logged in:", { userId: 123, username: "john" });
logger.log("API response:", response);

Using the Class Directly

import { RemoteLoggerClient } from "@khalidsheet/remote-logger-client";

const logger = new RemoteLoggerClient("MyApp", 4455);

logger.log("Application started");

Method Chaining

logger.log("Step 1 complete").log("Step 2 complete").log("All steps done!");

API

createLogger(app, port)

Factory function to create a new logger instance.

Parameters:

  • app (string, optional) - Application name to identify logs. Default: "default"
  • port (number, optional) - WebSocket server port. Default: 4455

Returns: RemoteLoggerClient instance

Example:

const logger = createLogger("MyApp", 4455);

new RemoteLoggerClient(app, port)

Constructor for creating a logger instance directly.

Parameters:

  • app (string, optional) - Application name. Default: "default"
  • port (number, optional) - WebSocket server port. Default: 4455

Example:

const logger = new RemoteLoggerClient("MyApp", 4455);

logger.log(...args)

Send logs to the remote server. Accepts any number of arguments of any type.

Parameters:

  • ...args (any[]) - Values to log (same as console.log)

Returns: this (for method chaining)

Example:

logger.log("Simple message");
logger.log("Multiple", "arguments", 123, true);
logger.log("Object:", { foo: "bar" });
logger.log("Array:", [1, 2, 3]);

How It Works

  1. Connection: The client automatically connects to the WebSocket server on instantiation
  2. Logging: When you call logger.log(), it sends the data to the server with:
    • Application name
    • Log message(s)
    • Caller information (file path, line, and column)
  3. Fallback: If disconnected, logs are sent to console.log instead
  4. Auto-reconnect: The client automatically attempts to reconnect every 3 seconds if the connection is lost

Message Format

The client sends logs in the following JSON format:

{
  "app": "MyApp",
  "message": ["Log message", { "data": "value" }],
  "caller": "http://localhost:3000/src/App.tsx:42:15"
}

Server Output

When you send logs, they appear on the server console in this format:

12:34:56 PM [MyApp] [App.tsx:42:15] Log message { data: "value" }

Configuration

Custom Port

If your remote logger server is running on a different port:

const logger = createLogger("MyApp", 8080);

Multiple Applications

You can create separate loggers for different parts of your application:

const authLogger = createLogger("Auth");
const apiLogger = createLogger("API");
const uiLogger = createLogger("UI");

authLogger.log("User logged in");
apiLogger.log("Fetching data from /api/users");
uiLogger.log("Modal opened");

Browser Compatibility

Works in all modern browsers that support WebSocket:

  • Chrome/Edge
  • Firefox
  • Safari
  • Opera

Requirements

  • Modern JavaScript environment with WebSocket support
  • Remote Logger Server running (usually on localhost:4455)

Development

Build

pnpm install
pnpm build

Builds the project using tsdown and outputs to the dist/ directory in both CommonJS and ESM formats.

Project Structure

@khalidsheet/remote-logger-client/
├── src/
│   └── main.ts          # Client implementation
├── dist/                # Built files
├── package.json
├── tsconfig.json
└── tsdown.config.ts     # Build configuration

Troubleshooting

Logs not appearing on the server

  1. Make sure the remote logger server is running:

    remote-logger-server
  2. Check the browser console for connection messages:

    [@khalidsheet/remote-logger-client] [MyApp] Connected.
  3. Verify the port matches between client and server (default: 4455)

Connection keeps retrying

If you see constant reconnection attempts, the server might not be running or is unreachable. The client will fall back to console.log in the meantime.

License

MIT

Related

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

Happy Hacking!