Giter VIP home page Giter VIP logo

node-graylog's Introduction

node-graylog

Graylog2 client library for Node.js

Synopsis

	require("graylog");

Short message:

	log("What we've got here is...failure to communicate");

Long message:

	log("What we've got here is...failure to communicate", "Some men you just 
		can't reach. So you get what we had here last week, which is the way he wants 
		it... well, he gets it. I don't like it any more than you men.");

Short with options:

	log("What we've got here is...failure to communicate", { level: LOG_DEBUG });

Long with options:

	log("What we've got here is...failure to communicate", "Some men you just 
		can't reach. So you get what we had here last week, which is the way he wants 
		it... well, he gets it. I don't like it any more than you men.", 
		{
			facility: "Steve Martin"
		}
	);

You can add custom fields to the options:

	log("What we've got here", { 
		level: LOG_DEBUG,
		_failure: "to communicate"
	});

Options

  • facility - by default it's set to GLOBAL.graylogFacility.
  • level - syslog levels, one of: LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO (default), LOG_DEBUG.
  • timestamp - unixtime of log event, by default it's now.
  • host - by default, it's auto detected.
  • stack - if set to true, log will contain source file name and line number.

Additional settings

You can set GLOBAL.graylogHost and GLOBAL.graylogPort to the host and port of the Graylog2 server. By defaults it's localhost and 12201.

You can set GLOBAL.graylogToConsole to true to log JSON entries to console as well (useful for development in case you don't want to have graylog2 running on your workstation).

You should set GLOBAL.graylogFacility to the name of your application. By default it's set to "Node.js".

You can set GLOBAL.graylogSequence to a integer non-zero value (set it to 1) to have an auto-incremented _graylogSequence field sent to graylog with each log entry. Due to the fact that UDP packets are not guaranteed to be received in the same order as sent, you might need a sequence number to recover the course of events.

Example

See sayHello.js.

Modification of the GLOBAL object?! But why?

I know, it's wrong. However I like it that way and I truly believe that logger function must be the easiest to call for the programmer to never hesitate using it. So I think that logger functions should be one of the extremely few cases where global namespace pollution is feasible.

What is graylog2 after all?

It's a miracle. Get it at http://www.graylog2.org/

Installation

npm install .

TODO

  • Limit messages size to MTU size?..

License

See LICENSE file. Basically, it's a kind of "do-whatever-you-want-for-free" license.

Author

Egor Egorov [email protected]

Contributors

  • danlangford (dan L)
  • andris9
  • pilsy

node-graylog's People

Contributors

egorfine avatar danlangford avatar pilsy avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.