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 🙏

© 2024 – Pkg Stats / Ryan Hefner

winston-nr

v1.2.5

Published

A lightweight and easy-to-use Winston transport for exporting logs to New Relic using HTTP requests.

Downloads

33

Readme

Winston New Relic Transport

NPM Version License Coverage Status

A simple, lightweight, and easy-to-use custom transport for Winston logger that exports logs to New Relic using HTTP requests. This library has no external dependencies, ensuring a lightweight and minimalistic solution.

Features

  • Simple and lightweight library with no external dependencies.
  • Custom transport for exporting logs to New Relic using HTTP requests.
  • Easy integration with your existing Winston logger configuration.
  • Supports compression of log payloads to optimize network utilization.
  • Optional batching of logs for efficient transmission to the New Relic Logs API.
  • Fine-grained control over batch size and batch timeout for optimal log handling.
  • Full unit test coverage for reliable and robust functionality.
  • Provides a flush method to manually flush the transport and ensure all logs are sent.
  • Written in TypeScript for enhanced type safety and editor support.

Installation

npm install winston-nr

Usage

import winston from 'winston';
import { NewRelicTransport } from 'winston-nr';

// Create the transport and a Winston logger instance and
const nrTransport = new NewRelicTransport({
  apiUrl: 'https://log-api.newrelic.com/log/v1',
  apiKey: 'YOUR_API_KEY',
  compression: true,
  retries: 3,
  batchSize: 10,
  batchTimeout: 5000,
});
const logger = winston.createLogger({
  transports: [nrTransport],
});

// Log a message
logger.info('Log message', { test: true });

// Manually flush the transport to ensure all logs are sent
await nrTransport.flush();
// Or, automatically trigger the flush by ending the logger
await new Promise(resolve =>
  logger.on('error', resolve).on('close', resolve).on('finish', logger.close).end()
);

// You can safely exit the app without losing your logs
process.exit(0);

Options

The NewRelicTransport accepts the following options:

  • apiUrl (required): The URL of the New Relic Logs API.
  • apiKey (required): The API key used to authenticate with the New Relic Logs API.
  • timeout: Timeout for the HTTP request in milliseconds (default: 5000).
  • retries: Number of times to retry failed requests (default: 0).
  • compression: Enable gzip compression for the log payload (default: false).
  • batchSize: Number of logs to batch together before sending.
  • batchTimeout: Time interval in milliseconds to wait for batching logs.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.