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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gelfr

v0.0.2

Published

Node package to receive GELF events

Downloads

13

Readme

GELF Receiver

This is a NodeJS module to implement a GELF receiver. The module can currently handle following kinds of GELF events.

  • Uncompresssed
  • GZIPed
  • ZLIBed
  • Chunked - The chunked message can again be any of the three formats above

API

To create a GELF receiver one must require('gelfr'),then call the createGELFServer() to create a server instance, subscribe to 'message' event and start the server.

var gelfr = require('gelfr');
var s = gelfr.createGELFServer();
s.on('message', function (msg) { console.log(JSON.stringify(msg) });
s.start();

Functions

createGELFServer(options)

Creates a new GELF receiver. The options argument is optional and can have following fields:

  • proto - udp4 or udp6. (Default: udp4)
  • port - port to listen for events. Default is 0 i.e. any random port available for listening
  • addr - address to bind to. (Default: '0.0.0.0')
  • listener - Listener function for message events. None by default
  • notifyBadMsg - true or false. If set emits badmessage event when invalid messages arrive. (Default: false)
  • chunkTTL - TTL for reconstruction of chunked messages in seconds. If all parts of a chunked message does not arrive within this time it will be dropped. (Default: 2 seconds)
  • parseJSON - ture or false - Set whether the message should be parsed as into a JSON object. (Default: false)

GELF Server Functions

createGELFServer(options) returns a receiver object. The receiver object has the following functions asssociated with it.

start()

Start the server

stop()

Stop the server

address()

Return the address of the server. Returns the IP address and port to which the receiver is listening to.

parseJSON(flag)

If no flag is passed returns whether the received message will be parsed into an object or not. If the flag is passed (true or false) then it enables/disables parsing of received message to an object.

Events

GELF Receiver emits following events

ready

function () { }

Emitted when server is ready to receive packets.

end

function () { }

Emitted when server has stopped and will no more receive any packets and will not emit any more events.

message

function (msg) { }

Emitted when a new message is received. For chunked messages this event will be emitted once all the chunks have been received and the message is reassembled. The msg argument passed is an object with following properties.

{
    compression: 'GZIP' or 'ZLIB' or 'NONE', /* compression method */
    chunked: true or false, /* whether the message was chunked */
    chunks: <int>, /* number of chunks. for non-chunked messages 1 */
    data: 'utf8-string' or Parsed-json-object, /* payload */
    sender: 'ip-address', /* ip adress string of the sender */
}

error

function (err) { }

Emitted when there is some error.

badmessage

function (err) { }

Emitted when a bad/invalid message is received and notifyBadMsg option was set to true when creating the listener. The err object looks like below:

{
    error: "error_string",
    data: Binary_data, /* the data packet that caused error */
    sender: 'ip-address', /* ip address of the sender */
}

License

(The MIT License)

Copyright(c) 2012 Yahoo! Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors

  • Damodharan Rajalingam (damu at yahoo-inc dot com)