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

loopback-component-bunyan

Package Overview
Dependencies
Maintainers
5
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-component-bunyan

Bunyan logger component for loopback

  • 3.0.1-traverseAndNyc7232.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

loopback-component-bunyan

Creates a Bunyan logger based on configuration in component-config.json file.

Here is a small example to illustrate:

{
	...
	"loopback-component-bunyan": {
		"level": "debug",
		"streams": [
			{
				"type": "prettystream",
			}
		]
	}
	...
}

The type property is one of the following supported stream types:

  • prettystream
  • logentries
  • LogDNA

Unfortunately Bunyan does not support a stream registry the way Winston does, so for now this project will need to explicitly include the necessary streams.

Getting a Log object

The configuration above attaches a method app.logger which can be used to obtain a new logger for your module:

   let log = app.logger('MyComponent');

   log.debug({}, 'My log message');

requestLogger Middleware

The component comes with a request logging middleware. Bellow is an example of how it can be connected.

# middleware.json
{
	...
	"routes": {
		"loopback-component-bunyan#requestLogger": {
			"params": {
				"level": "info",
				"msg": "${res.statusCode} ${req.method} ${res.time}ms ${req.decodedUrl}",
				"meta": false
			}
		},
		...
	}
	...
}

Available options:

  • level [String] log level to report request
  • msg [String] message template
  • meta [Boolean] whether or not to include request/response meta information such as headers, body, query...

Keywords

FAQs

Package last updated on 16 Oct 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

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