项目作者: saikatharryc

项目描述 :
Logging component for loopback with add performance instrumentation for remote methods and datasource calls
高级语言: JavaScript
项目地址: git://github.com/saikatharryc/loopback-bunyan-looger.git
创建时间: 2017-04-24T14:47:51Z
项目社区:https://github.com/saikatharryc/loopback-bunyan-looger

开源协议:GNU General Public License v3.0

下载


loopback-bunyan-looger

updated {loopback-component-looger}

**incase if you dont want the child node logs. please use the version ^1.1.2

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

NPM NPM

Build Status

Features

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

Usage

Example server.js:

  1. var loopback = require('loopback');
  2. var boot = require('loopback-boot');
  3. var rootlooger = bunyan.createlooger({name: 'myloopbackAPI'});
  4. var looger = require('loopback-bunyan-looger')(rootlooger);
  5. var app = module.exports = loopback();

If rootlooger is not provide, the component creates a looger with default
bunyan settings:

  1. var loopback = require('loopback');
  2. var boot = require('loopback-boot');
  3. var looger = require('loopback-bunyan-looger')();
  4. var app = module.exports = loopback();

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

  1. var looger = require('loopback-bunyan-looger')('TestModel');
  2. module.exports = function(TestModel) {
  3. looger.debug('Initializing TestModel');
  4. };

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

  1. {
  2. "loopback-component-explorer": {
  3. "mountPath": "/explorer"
  4. },
  5. "loopback-bunyan-looger": {
  6. "enableAPI" : true
  7. }
  8. }

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