winston-loggly-bulk
A Loggly transport for winston
Last updated 13 hours ago by loggly-hoover .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install winston-loggly-bulk 
SYNC missed versions from official npm registry.

winston-loggly-bulk

A Loggly transport for winston.

Version npmnpm Downloads

NPM

A client implementation for Loggly in node.js. Check out Loggly's Node logging documentation for more.

Usage

  var winston = require('winston');

  //
  // Requiring `winston-loggly-bulk` will expose
  // `winston.transports.Loggly`
  //
  var {Loggly} = require('winston-loggly-bulk');

  winston.add(new Loggly({options}));

The Loggly transport is based on Nodejitsu's node-loggly implementation of the Loggly API. If you haven't heard of Loggly before, you should probably read their value proposition. The Loggly transport takes the following options.

  • subdomain: The subdomain of your Loggly account. [required]
  • token: The access token (previously inputToken) [required]
  • auth: The authentication information for your Loggly account.
  • json: If true, messages will be sent to Loggly as JSON.
  • tags: An array of tags to send to loggly.
  • isBulk: If true, sends messages using bulk url
  • stripColors: Strip color codes from the logs before sending
  • bufferOptions: Buffer options has two configurations.
    • size: Number of logs to be buffered.
    • retriesInMilliSeconds: Time in milliseconds to retry sending buffered logs.
  • timestamp: If false, library will not include timestamp in log events.
    • Note: Library includes timestamp by default when we do not set timestamp option.
  • networkErrorsOnConsole: The library keep track of different network errors and can log them to console. By default, logging errors on console is disabled and can be enabled easily by setting this parameter's value to true. If true, all the network errors will be logged to console.

Sample Working Code Snippet

var winston  = require('winston');
var { Loggly } = require('winston-loggly-bulk');

winston.add(new Loggly({
    token: "TOKEN",
    subdomain: "SUBDOMAIN",
    tags: ["Winston-NodeJS"],
    json: true
}));

winston.log('info', "Hello World from Node.js!");

Buffer Support

This library has buffer support during temporary network outage. User can configure size of buffer (no. of logs to be stored during network outage).

Add these below configuration in code snippet to override the default values of buffer option size and retriesInMilliSeconds.

bufferOptions: {
  size: 1000,
  retriesInMilliSeconds: 60 * 1000
}  
  • Note: The default value of buffer size and retries in milliseconds are 500 and 30000 (30 seconds) respectively.

Flush logs and exit

Our library uses ajax requests to send logs to Loggly, and as ajax requests take time to complete, logs can be lost when process.exit() is called because it forces an immediate exit. To exit gracefully and ensure that the last logs get to Loggly, we created a function called flushLogsAndExit(). It waits for 10 seconds and then calls process.exit() itself. This allows enough time for the logs to be sent to Loggly.

Here is an example of how to use the method:

var winston = require('winston');
var { flushLogsAndExit } = require('winston-loggly-bulk');

winston.log("info", "Hello World from Node.js!");
flushLogsAndExit();

Motivation

tldr;?: To break the winston codebase into small modules that work together.

The winston codebase has been growing significantly with contributions and other logging transports. This is awesome. However, taking a ton of additional dependencies just to do something simple like logging to the Console and a File is overkill.

Installation

  npm install winston-loggly-bulk

Note: If you are using npm version 2, please run the below command:

  npm install winston-loggly-bulk winston

Run Tests

Written in Jest. Testing that log events are correctly passed on.

  npm test

Author: Charlie Robbins

Contributors: Loggly, Shweta Jain,

Current Tags

  • 3.1.0-alpha                                ...           alpha (4 months ago)
  • 3.0.0                                ...           beta (2 years ago)
  • 3.1.1                                ...           latest (13 hours ago)

25 Versions

  • 3.1.1                                ...           13 hours ago
  • 3.1.0                                ...           4 months ago
  • 3.1.0-alpha                                ...           4 months ago
  • 3.0.3-alpha2                                ...           5 months ago
  • 3.0.3-alpha                                ...           5 months ago
  • 3.0.2-alpha                                ...           5 months ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.5-beta                                ...           2 years ago
  • 2.0.4-beta                                ...           2 years ago
  • 2.0.3-beta                                ...           2 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.4.2                                ...           3 years ago
  • 1.4.1                                ...           3 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.7                                ...           4 years ago
  • 1.3.6                                ...           4 years ago
  • 1.3.5                                ...           4 years ago
  • 1.3.4                                ...           4 years ago
  • 1.3.3                                ...           4 years ago
  • 1.3.2                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
Maintainers (2)
Downloads
Today 7
This Week 22
This Month 23
Last Day 15
Last Week 0
Last Month 16
Dependencies (4)
Dev Dependencies (1)
Dependents (107)

Copyright 2014 - 2016 © taobao.org |