Socket
Book a DemoInstallSign in
Socket

mwp-logger-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1523
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mwp-logger-plugin

Hapi logging plugin for MWP apps

latest
Source
npmnpm
Version
27.0.28
Version published
Weekly downloads
3
-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

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');
}

FAQs

Package last updated on 19 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts