Neglected Pulse Machine

    feathers-service-logger-stats

    0.1.2 • Public • Published

    feathers-service-logger-stats

    This package is deprecated. It has been moved to feathers-profiler. There are some straight forward breaking changes.

    Build Status Code Climate Test Coverage Dependency Status Download Status

    Log service method calls and gather performance stats on them.

    Logs service calls

    The log message may be customized. The default log message includes:

    • Service name, method and transport provider.
    • Elapsed time between the method being called and its completion.
    • Number of service calls pending when call was made.
    • Where service call failed and why.

    logs

    Gathers performance stats on service calls

    Performance statistics are:

    • Grouped by service and method.
    • Grouped by characteristics of the call. These may be customized.
    • Average pending count provides information on how busy the server was during these calls.
    • Average, min and max elapsed time provide information on how responsive the server is.
    • The number of returned items provides information on how large the find results were.

    stats

    Installation

    npm install feathers-service-logger-stats --save
    

    Example

    npm start
    

    Documentation

    app.configure(loggerStats(options))

    logger

    • defaults to logging on console.log.
    • null disables logging.
    • require('winston') routes logs to the popular winston logger.
    • { log: payload => {} } routes logs to your customized logger.

    logMsg

    • default message is shown above.
    • hook => {} returns a custom string or object payload for the logger. hook._log contains log information; hook.original and hook.error contain error information.

    stats

    • null or none statistics will not be gathered.
    • total gathers statistics by service and method only. The default.
    • detail gathers statistics by characteristics of the call.

    statsDetail

    • default is shown above.
    • hook => {} returns a custom category for the call.

    Please refer to the logger documentation for more details.

    Complete Example

    Here's an example of a Feathers server that uses feathers-service-logger-stats.

    const feathers = require('feathers');
    const rest = require('feathers-rest');
    const sockets = require('feathers-socketio');
    const hooks = require('feathers-hooks');
    const bodyParser = require('body-parser');
    const errorHandler = require('feathers-errors/handler');
     
    // import { loggerStats, getPending, getStats } from 'feathers-service-logger-stats';
    const loggerStats = require('feathers-service-logger-stats').loggerStats;
    const getPending = require('feathers-service-logger-stats').getPending;
    const getStats = require('feathers-service-logger-stats').getStats;
     
    // Initialize the application
    const app = feathers()
      .configure(rest())
      .configure(sockets())
      .configure(hooks())
      .use(bodyParser.json()) // Needed for parsing bodies (login)
      .use(bodyParser.urlencoded({ extended: true }))
      .use('users', { ...}) // services
      .use('messages', { ... })
      .configure(loggerStats({ stats: 'detail' }) // must be configured after all services
      .use(errorHandler());
      
      // once multiple service calls have been made
      console.log('pending', getPending());
      console.log(require('util').inspect(getStats(), {
        depth: 5,
        colors: true
      }));
     

    License

    Copyright (c) 2016

    Licensed under the MIT license.

    Install

    npm i feathers-service-logger-stats

    DownloadsWeekly Downloads

    0

    Version

    0.1.2

    License

    MIT

    Last publish

    Collaborators

    • eddystop