This package has been deprecated

Author message:

Abandoned a long time ago, many alternative node modules exists today

graylog

0.1.5 • Public • Published

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.

You can set GLOBAL.graylogChunkSize to the maximum allowed bytes for a single UDP packet. Log messages higher than that will be sent in chunked encoding.

You can set GLOBAL.additionalFields for any properties that would like to include on every log message.

You can set GLOBAL.gelfVersion for initialize gelf spec version. By default it is set to 1.1.

GLOBAL.additionalFields = {
    _environment: "Dev",
    _version: "1.0"
}

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 .

License

MIT

Author

Egor Egorov me@egorfine.com.

Contributors

  • danlangford (dan L)
  • andris9
  • pilsy
  • micahlmartin

Readme

Keywords

none

Package Sidebar

Install

npm i graylog

Weekly Downloads

15

Version

0.1.5

License

none

Last publish

Collaborators

  • egorfine