🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

loopback-component-winston

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-component-winston

Winston logger component for loopback

0.0.3
latest
Source
npm
Version published
Weekly downloads
108
50%
Maintainers
1
Weekly downloads
 
Created
Source

loopback-component-winston

Creates winston logger based on configuration in component-config.json file. Here is a small example to illustrate:

{
	...
	"loopback-component-winston": {
		"level": "verbose",
		"transports": [
			{
				"type": "Console",
				"json": true
			}, {
				"type": "File",
				"name": "info-file",
				"filename": "error.log",
				"level": "info"
			}, {
				"type": "File",
				"name": "error-file",
				"filename": "error.log",
				"level": "error"
			}
		]
	}
	...
}

The configuration above creates an instance of winston.Logger and binds it to a globally accessible app.log property. The type property of transport descriptors denotes the name of the class in winston.transports scope.

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-winston#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

loopback

FAQs

Package last updated on 04 Oct 2019

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