3.0.1-traverseAndNyc7232.1 • Published 2 years ago

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

Weekly downloads
184
License
MIT
Repository
github
Last release
2 years 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

2 years ago

3.0.1-qs653.1

2 years ago

3.0.0

2 years ago

2.1.0-node.1

2 years ago

2.1.0-node.3

2 years ago

2.1.0-node.2

2 years ago

2.1.0-node.5

2 years ago

2.1.0-node.4

2 years ago

2.0.0

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.1-lodash.5

4 years ago

1.3.0

7 years ago

1.2.1-circle.2

7 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.6

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago