Coder Social home page Coder Social logo

loopback-bunyan-logger's Introduction

loopback-bunyan-logger

updated {loopback-component-logger}

**incase if you dont want the child node logs. please use the version ^1.1.2 of loopback-bunyan-looger.

Logging component for loopback using bunyan logger with additional loopback specific hooks and log management API

NPM NPM

Build Status Greenkeeper badge

Features

  • Default logger using bunyan
  • Can use of custom bunyan streams to create root logger
  • Hook: Basic performance instrumentation for remote execution
  • Hook: Log management API (configurable)

Usage

Example server.js:

var loopback = require('loopback');
var boot = require('loopback-boot');
var rootlogger = bunyan.createlogger({name: 'myloopbackAPI'});
var logger = require('loopback-bunyan-logger')(rootlogger);
var app = module.exports = loopback();

If rootlogger is not provide, the component creates a logger with default bunyan settings:

var loopback = require('loopback');
var boot = require('loopback-boot');
var logger = require('loopback-bunyan-logger')();
var app = module.exports = loopback();

Child loggers can be created for model as shown below. By default child loggers inherit the log level from root.

var logger = require('loopback-bunyan-logger')('TestModel');
module.exports = function(TestModel) {
    logger.debug('Initializing TestModel');
};

To add hooks and log management API to loopback, add configuration to component-config.json:

{
  "loopback-component-explorer": {
    "mountPath": "/explorer"
  },
  "loopback-bunyan-logger": {
      "enableAPI" : true
  }
}

Make sure enableHttpContext is set as true in config.json for to allow collection of datasources performance within req/res If you dont want expand the child nodes please use version @1.1.2

License

GNU

Create Issue

Create issue here here

Roadmap

  • Additional Unit Test and Coverage
  • Integrate with Strongloop Devops tools

Known Issue

  • datasources performance will not recorded at times when loopback context is null. Noticed this issue when a composite called MongoDB followed by REST. Only MongoDB response time was recorded and REST was missing.

See Also

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.