GithubHelp home page GithubHelp logo

kt3k / node-es-logger Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 2.0 10 KB

:sparkle: Creates bunyan logger bound to elasticsearch output.

Home Page: https://www.npmjs.com/package/es-logger

License: MIT License

JavaScript 100.00%

node-es-logger's Introduction

node-es-logger v0.3.0

This module creates a bunyan logger instance with an output stream bound to elasticsearch instance with logstash compatible JSON format.

Options

  • name (required): Bunyan log name
  • host: Elasticsearch host. Defaults to localhost:9200
  • type: String or function, Elasticsearch type for log entry to be stored under
  • client: Elasticsearch client. See elasticsearch-js for more details. Useful when custom client options are needed, like setting the Elasticsearch client log level. When used, host is ignored
  • indexPattern: Pattern used to generate index name. See momentjs for more details. Defaults to [logstash-]YYYY.MM.DD
  • index: String or function, Elasticsearch index to store log entry under. When used, indexPattern is ignored
  • serializers: Array of objects, bunyan serializers. See node-bunyan for more details. Defaults to standard serializers
  • quiet: Boolean, whether to add the stdout stream to the logger

Minimal Example

var logger = require('es-logger').create({

    name: 'myapp'

});

logger.info({value: 123}, 'message');

This prints a JSON and also send it to elasticsearch instance at localhost:9200.

Example with type from function

var logger = require('es-logger').create({

    name: 'myapp',
    host: 'elasticsearch:9200',
    type: function (entry) {
        return entry['type'];
    }
});

logger.info({type: "request", method: "GET"});

Use with bonsai.io.

var logger = require('es-logger').create({

    name: 'myapp',
    host: 'username:[email protected]'

});

logger.info({value: 123}, 'message');

This prints a JSON and also send it to bonsai's elasticsearch instance at myapp-name-123456789.us-west-2.bonsai.io.

see bunyan's README for what interfaces the logger has.

node-es-logger's People

Contributors

figadore avatar kt3k avatar reesew avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

figadore

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.