mwp-logger-plugin

27.0.28 • Public • Published

Logging

We use Bunyan for server-side logging in the platform, which provides JSON-encoded logs for production and a pretty- printing CLI for dev.

Usage

In general, server code should prefer to access the logger through the Hapi server instance at server.app.logger.

// Direct `server` access
function myModule(server) {
  server.app.logger.info('Hello module');
}

// Access through `request.server`
function requestHandler(request) {
  request.server.app.logger.info('Hello request handler');
}

// Access through `response.request.server`
function responseHandler(response) {
  response.request.server.app.logger.info('Hello response handler');
}

If a module does not have access to the server instance, the logging instance can also be imported directly at the cost of function purity and slightly more complex unit testing configuration to mock the logger module.

import { logger } from 'mwp-logger-plugin';

function doStuff() {
  logger.info('Hello stuff');
}

Readme

Keywords

none

Package Sidebar

Install

npm i mwp-logger-plugin

Weekly Downloads

884

Version

27.0.28

License

MIT

Unpacked Size

48.6 kB

Total Files

15

Last publish

Collaborators

  • meetupbot