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

@ahmedosama94/winston-gelf-transporter

v1.1.4

Published

A Winston transporter for sending GELF messages

Downloads

3,986

Readme

winston-gelf-transporter

This is fork of winston-gelf-transporter (original package no longer maintained)

A Winston transporter for sending GELF messages to your Graylog server.

Setup

Installation

To install with npm

npm install @ahmedosama94/winston-gelf-transporter

Importing

ES6 style

import WinstonGelfTransporter from '@ahmedosama94/winston-gelf-transporter';

CommonJS

const WinstonGelfTransporter = require('@ahmedosama94/winston-gelf-transporter');

Configuration

You can create a new transporter as such

const transporter = new WinstonGelfTransporter();

You can also pass a TransporterOptions object to the constructor

const transporter = new WinstonGelfTransporter({
  version?: string,
  host?: string,
  port?: number,
  protocol?: string,
  hostName?: string,
  additional?: Object,
  // + winston's default `TransportStreamOptions`
});

TransportStreamOptions

coloring or styling formatters will not work: Formatters should only be used for text transformations!

Usage

All you need to do is add the transporter to your winston logger.

import winston from 'winston';
import WinstonGelfTransporter from '@ahmedosama94/winston-gelf-transporter';

logger = winston.createLogger({
  level: winston,
  transports: [
    winston.transports.Console,
    // Add the Graylog transporter to the logger
    new WinstonGelfTransporter({
      host: 'graylog.example.com',
      port: 12345,
      hostName: 'client.example.com',
      additional: {
        foo: 'Bar'
      }
    })
  ]
});

// 1. Log a string
logger.info('Something');
// 2. Log an object
logger.info({ hello: 'world' });
// 3. Log a string message with object
logger.info('Something', { hello: 'world' });
// 4. Log an error
logger.error(new Error());
// 5. Log an error with a message
logger.error(new Error('Something'));
// 6. Or log a message with an error
logger.error('Something', new Error());

The above logging statements will result in the following

1.
{
  "version":"1.1",
  "short_message":"Something",
  "timestamp":1577041912.451,
  "host":"client.example.com",
  "level":6,
  "foo": "Bar"
}
2.
{
  "version":"1.1",
  "short_message":"{\"hello\":\"world\"}",
  "timestamp":1577041912.452,
  "host":"client.example.com",
  "level":6,
  "foo": "Bar"
}
3.
{
  "version":"1.1",
  "short_message":"{\"message\":\"Something\",\"hello\":\"world\"}",
  "timestamp":1577041912.452,
  "host":"client.example.com",
  "level":6,
  "foo": "Bar"
}
4.
{
  "version":"1.1",
  "short_message":"Error",
  "timestamp":1577041912.453,
  "host":"client.example.com",
  "full_message":"Error\n <extended stack trace>",
  "level":3,
  "foo": "Bar"
}
5.
{
  "version":"1.1",
  "short_message":"Something",
  "timestamp":1577041912.453,
  "host":"client.example.com",
  "full_message":"Error: Something\n <extended stack trace>",
  "level":3,
  "foo": "Bar"
}
6.
{
  "version":"1.1",
  "short_message":"Something",
  "timestamp":1577041912.453,
  "host":"client.example.com",
  "full_message":"Error\n <extended stack trace>",
  "level":3,
  "foo": "Bar"
}