Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hmcts/nodejs-logging

Package Overview
Dependencies
Maintainers
16
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hmcts/nodejs-logging

[![Greenkeeper badge](https://badges.greenkeeper.io/hmcts/nodejs-logging.svg)](https://greenkeeper.io/)

  • 4.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.5K
decreased by-16.6%
Maintainers
16
Weekly downloads
 
Created
Source

Node.js Logging

Greenkeeper badge

A logging component used by Reform's Node.js applications.

This is not compatible with Reform tactical logging spec. Logger 2.x should be used for tactical applications.

Some background info:

  • there are 6 log levels: silly (5), debug (4), verbose (3), info (2), warn (1) and error (0).
  • log level can be set via an environment variable LOG_LEVEL, the default is info.
  • logging output in JSON format can be enabled by setting environment variable JSON_PRINT to true, the default is false:
  • by default logging is turned off when running the unit tests.

Usage

Add it as your project's dependency:

yarn add @hmcts/nodejs-logging

Require it:

const { Logger } = require('@hmcts/nodejs-logging')

Then you can create a logger instance and use it to log information:

const logger = Logger.getLogger('app.js') // app.js is just an example, can be anything that's meaningful to you

Usage are:

logger.info({
  message: 'Yay, logging!'
})

or

logger.log({
  level: 'info',
  message: 'What time is the testing at?'
});

Above will result in the following log printed (if JSON format is enabled).

{ level: 'info',
  message: 'What time is the testing at?',
  label: 'app.js',
  timestamp: '2017-09-30T03:57:26.875Z' }

Access logging for Express applications

Optionally you can use the built-in Express access logger:

const { Express } = require('@hmcts/nodejs-logging')

app.use(Express.accessLogger())

Units Tests

Just do

yarn test

License

This project is licensed under the MIT License - see the LICENSE file for details.

FAQs

Package last updated on 07 Jul 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc