3.0.1-traverseAndNyc7232.1 • Published 7 months ago

loopback-component-bunyan v3.0.1-traverseAndNyc7232.1

Weekly downloads
184
License
MIT
Repository
github
Last release
7 months ago

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:

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...
2.1.0-node.6

1 year ago

3.0.1-qs653.1

1 year ago

3.0.0

1 year ago

2.1.0-node.1

1 year ago

2.1.0-node.3

1 year ago

2.1.0-node.2

1 year ago

2.1.0-node.5

1 year ago

2.1.0-node.4

1 year ago

2.0.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.1-lodash.5

3 years ago

1.3.0

6 years ago

1.2.1-circle.2

6 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.6

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago