Skip to content

DexterYan/bunyan-logstash-tcp-consolelog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A TCP console log for Bunyan

build status A replacement of console.log with logstash tcp, and auto reconnect when error or disconnec appears. It also exports the bunyanlog for modifing.

Credits

This module is heavily based on bunyan-logstash-tcp.

Usage

    var bunyan = require('bunyan-logstash-tcp-consolelog');
    var options = {};
    var streamsOptions = {};
    var bunyanLog;

    options.project_name = 'test bunyan console log';
    options.name = 'test';
    
    options.level = 'debug';

    streamsOptions.host = '127.0.0.1';
    streamsOptions.port = '9998';

    bunyanLog = bunyan.createLogger(options, streamsOptions);

    console.log('log test');
    console.warn('warn test');
    console.error('error test');

    bunyanLog.error('bunyan error test');

Configuration

You can use default setting without passing, or passing options and streamsOptions

Options is to configure the bunyan module, the name is required. You can add other parameters

ParameterTypeDefault
name string undefined

streamOption is to configure the TCP stream.

level string info
server string os.hostname()
host string "127.0.0.1"
port number 9999
application string process.title
pid string process.pid
tags array|string[] ["bunyan"]

Installation

$ npm install bunyan-logstash-tcp-consolelog

Events

Inside the console.log stream will emit open, close and error. Once it emit error or close, it will start auto reconnect based on Retry Algorithm;

Logstash Configuration

Configuration for Logstash 1.3.3+:

input {
  // config for bunyan udp
  udp {
      'port' => "9999"
  }
  // config for bunyan tcp
  tcp {
      'port' => "9998"
  }
}

Try with logstash locally

  • Download logstash from http://logstash.net/
  • Unpack it (tar -zxf logstash-1.5.0.tar.gz)
  • Create a test logstash configuration logstash.conf
input {
  stdin { 
    type => "stdin-type"
  }
  udp {
    port => "9999"
  }
  tcp {
    port => "9998"
  }
}
output { 
  stdout {}
}
  • Run `bin/logstash agent -f logstash.conf
  • Run node example/log.js

Example Website

www.safetyflights.com is a flight Safety search engine that organizes Flight Information, Aviation Accidents Records and Airline Information to help you to choose suitable flight.

License

The MIT License (MIT) Copyright © 2015 Dexter Yan

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.

About

A replacement of console.log with logstash tcp, and auto reconnect when error or disconnec appears.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published