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

devlogs-browser

v2.3.1

Published

Browser logging library for DevLogs - forwards console logs to OpenSearch

Downloads

652

Readme

devlogs-browser

Browser logging library for DevLogs - forwards console logs to OpenSearch or a collector endpoint.

How It Works

devlogs-browser captures logs by intercepting console.log, console.warn, console.error, console.debug, and console.info. After calling init(), every console call is wrapped: the original method is called first (so browser DevTools still work normally), then the log entry is formatted and sent to your configured backend via fetch.

This means:

  • Any code that calls console.error("something failed") will automatically have that error captured and forwarded.
  • Code that handles errors silently (e.g. a catch block that calls setState() but never console.error()) will not be captured. Add a console.error() call to make those visible.
  • Uncaught exceptions and unhandled promise rejections are not captured by default because they don't go through console.*. Call installGlobalHandlers() after init() to capture these automatically.

Installation

npm install devlogs-browser

Quick Start

import * as devlogs from 'devlogs-browser';

devlogs.init({
  url: 'http://admin:admin@localhost:9200',
  index: 'devlogs-myapp',
  application: 'my-frontend',
  component: 'dashboard',
  area: 'frontend'
});

// Capture uncaught errors and unhandled promise rejections
devlogs.installGlobalHandlers();

// Now all console output and uncaught errors are forwarded
console.log('Hello from browser!');

Usage

OpenSearch mode (direct)

import * as devlogs from 'devlogs-browser';

devlogs.init({
  url: 'http://admin:admin@localhost:9200',
  index: 'devlogs-myapp',
  application: 'my-frontend',
  component: 'dashboard',
  area: 'frontend'
});

// Now console.log/warn/error/info are forwarded to OpenSearch
console.log('Hello from browser!');

Collector mode

import * as devlogs from 'devlogs-browser';

devlogs.init({
  url: 'https://[email protected]',
  application: 'my-frontend',
  component: 'dashboard',
  area: 'frontend'
});

// Logs are sent to the collector with Bearer token auth
console.log('Hello via collector!');

URL format detection

The mode is auto-detected from the URL:

  • http://user:pass@host:port — OpenSearch mode (Basic auth)
  • https://token@host:port — Collector mode (Bearer token)
  • https://host:port — Collector mode (no auth)
  • opensearch:// / opensearchs:// — Force OpenSearch mode

Capturing uncaught errors

By default, devlogs only captures explicit console.* calls. To also capture uncaught exceptions and unhandled promise rejections, call installGlobalHandlers() after init():

devlogs.init({ url: '...', application: 'my-app', component: 'ui' });
devlogs.installGlobalHandlers();

// These are now captured:
// - Uncaught throw new Error('oops')
// - Unhandled Promise.reject('failed')

The global handlers use addEventListener, so they won't interfere with any existing window.onerror or window.onunhandledrejection handlers in your application. They are automatically removed when you call destroy().

Production Deployment

Devlogs is a development tool and should not run in production:

Option 1: Conditional initialization

if (process.env.NODE_ENV === 'development') {
  devlogs.init({ url: '...', application: '...', component: '...' });
  devlogs.installGlobalHandlers();
}

Option 2: Don't import at all

Only import devlogs in development - bundlers will tree-shake it out of production builds.

API

  • init(options) - Initialize and intercept console methods
  • destroy() - Restore original console methods and remove global handlers
  • installGlobalHandlers() - Capture uncaught errors and unhandled promise rejections (call after init())
  • setArea(area) - Set the current area
  • setOperationId(id) - Set the current operation ID
  • withOperation(id, fn) - Run function with temporary operation context
  • setFields(fields) - Set custom fields to include in all logs