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

@bazambazi/node-graylogger

v0.2.0

Published

A custom logger library

Readme

node-graylogger

Description

A versatile Node.js logger library designed for flexible log reporting over HTTP and RabbitMQ to graylog. This module is highly configurable and allows you to report errors and informational messages to different transports, making it suitable for various application environments.

Features

  • Multiple Transport Options: Supports sending logs via HTTP POST requests or through RabbitMQ queues.
  • Configurable Log Levels: Define different log levels to categorize and filter messages based on severity (e.g., INFORMATIONAL, ERROR, ALERT).
  • Error Reporting: Specialized error reporters for API, socket, and Axios errors, providing detailed context for debugging.
  • Automatic Reconnection: For RabbitMQ transport, the library includes automatic reconnection logic.
  • Detailed Log Objects: Logs include contextual information such as hostname, timestamp, log level, environment, and request-specific data (API, socket).
  • Easy Integration: Simple to integrate into any Node.js project as an npm module.

Installation

npm i @bazambazi/node-graylogger

Usage

Initialization

Initialize the logger with your configuration:

const Logger = require('@bazambazi/node-graylogger');

const loggerConfig = {
    transport: 'console', // 'http', 'amqp', or 'console'
    env: 'development', // Environment name
    appName: 'My Application' // Application name
};

const logger = new Logger(loggerConfig);

logger.init().then(() => {
    // Logger initialized
});

Reporting Logs

You can report different types of logs using the logger instance:

// Informational log
logger.reportInfo('User logged in', 'User JohnDoe successfully logged into the system', { userId: 'JohnDoe123' });

// Error log
logger.reportGeneralError(new Error('Database connection failed'), { databaseName: 'usersDB' });

// API error log (example with axios error)
axios.get('https://api.example.com/data')
    .catch(error => {
        error.errorType = 'axios';
        logger.error(error, { some: 'data' });

        // or
        logger.reportAxiosError(error, { some: 'data' });
    });

// Unexpected error log
try {
    // Some code that might throw an error
    throw new Error('Something unexpected happened');
} catch (e) {
    logger.reportUnexpectedError(e, { component: 'userService' });
}

Configuration Options

| Option | Description | Default Value | |--------------------|----------------------------------------------------------------|---------------| | transport | Transport for logs: http, amqp, or console. | console | | httpUrl | HTTP endpoint for sending logs in http transport mode. | - | | httpAuthUsername | username for basic auth in http transport. | - | | httpAuthPassword | password for basic auth in http transport. | - | | httpTimeout | timeout for http requests in http transport mode. (unit: ms) | 2000 | | amqpHost | RabbitMQ hostname in amqp transport mode. | 127.0.0.1 | | amqpPort | RabbitMQ port in amqp transport mode. | 5672 | | amqpUser | RabbitMQ username in amqp transport mode. | guest | | amqpPassword | RabbitMQ password in amqp transport mode. | guest | | amqpQueue | RabbitMQ queue name in amqp transport mode. | default_queue | | amqpRetryDelay | RabbitMQ retry delay in ms to connect in amqp transport mode.| 1000 | | env | Environment name (e.g., 'development', 'production'). | - | | appName | Application name. | - |