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

consolebridge

v1.0.3

Published

Enhanced console logging with remote capabilities

Downloads

8

Readme

ConsoleBridge

Enhanced console logging with colorization and remote capabilities for Node.js applications.

Features

  • 🎨 Colorized Console Output: Improve readability with color-coded log levels
  • 🌐 Remote Logging: Send selected logs to a remote server endpoint
  • 🔄 Preserve Original Console: Easily restore original console behavior
  • 🛠️ Configurable: Customize behavior with simple options
  • 📝 Custom Log Method: Special console.text() method for remote logging

Installation

npm install ConsoleBridge

Quick Start

const { createConsoleBridge } = require('ConsoleBridge');

// Initialize with default options
const ConsoleBridge = createConsoleBridge();

// Use enhanced console methods
console.log('Regular log message');
console.info('Info message in blue');
console.warn('Warning message in yellow');
console.error('Error message in red');
console.debug('Debug message in green');

// Use custom text method (for remote logging)
console.text('This can be sent to a remote server if configured');

// When done, restore original console behavior
ConsoleBridge.restore();

Configuration

const { createConsoleBridge } = require('ConsoleBridge');

const ConsoleBridge = createConsoleBridge({
  // Remote logging endpoint (optional)
  endpoint: 'https://your-logging-api.com/logs',
  
  // API key for authentication (optional)
  apiKey: 'your-api-key',
  
  // Enable/disable colorization (default: true)
  colorize: true,
  
  // Enable/disable console output (default: false)
  silent: false
});

Using with React

Basic Setup

// src/logger.js
import { createConsoleBridge } from 'ConsoleBridge';

export const logger = createConsoleBridge({
  endpoint: process.env.REACT_APP_LOGGING_ENDPOINT,
  apiKey: process.env.REACT_APP_LOGGING_API_KEY
});
// src/index.js or App.js
import { logger } from './logger';

// Initialize logger early in your app
logger.init();

// Use in your components
function App() {
  useEffect(() => {
    console.info('App mounted');
    console.text('This will be sent to the server');
    
    // Cleanup on unmount
    return () => logger.restore();
  }, []);

  return <div>Your App</div>;
}

Custom Hook

// src/hooks/useLogger.js
import { useEffect } from 'react';
import { createConsoleBridge } from 'ConsoleBridge';

export function useLogger(config = {}) {
  useEffect(() => {
    const logger = createConsoleBridge(config);
    logger.init();
    
    return () => logger.restore();
  }, []);
}

// Usage in component
function MyComponent() {
  useLogger({
    endpoint: 'https://api.example.com/logs',
    colorize: true
  });

  return <div>Component with logging</div>;
}

Remote Logging

Only the console.text() method sends logs to the remote server. Other console methods are enhanced but only output locally.

// Configure with remote endpoint
const ConsoleBridge = createConsoleBridge({
  endpoint: 'https://your-logging-api.com/logs',
  apiKey: 'your-api-key'
});

// This will be sent to the remote server
console.text('Important information to log remotely');

// These will only appear in the local console
console.log('Local log message');
console.info('Local info message');

Advanced Usage

Manual Initialization

const { ConsoleBridge } = require('ConsoleBridge');

// Create instance without auto-initialization
const logger = new ConsoleBridge({
  colorize: true,
  endpoint: 'https://your-logging-api.com/logs'
});

// Initialize when ready
logger.init();

// Use enhanced console
console.log('Console is now enhanced');

// Restore when done
logger.restore();

API Reference

createConsoleBridge(config)

Creates and initializes a new ConsoleBridge instance.

  • config (Object): Configuration options
    • endpoint (String): URL for remote logging
    • apiKey (String): Authentication key for remote endpoint
    • colorize (Boolean): Whether to colorize console output (default: true)
    • silent (Boolean): Whether to suppress console output (default: false)

Returns an initialized ConsoleBridge instance.

ConsoleBridge

Class that provides console enhancement functionality.

Methods

  • init(): Overrides console methods with enhanced versions
  • restore(): Restores original console behavior

Examples

See the examples directory for more usage examples.

License

MIT