mnr-req-logger
v2.0.0
Published
Opinionated wrapper around morgan logger middleware for node.js
Downloads
85
Readme
mnr-req-logger
Opinionated wrapper around morgan logger middleware for node.js
You may not need it!
This is a custom highly opinionated solution aimed at code reuse for a few private projects. You'd be better off using morgan directly.
v2 Breaking Changes
From v2,
mnr-req-logger
is an ESM-only module - you are not able to import it withrequire()
.Bump minimum supported version of Node.js to v20.
Archive documentation:
- v1;
Installation
$ npm install --save mnr-req-logger
Usage example
import mnrReqLogger from 'mnr-req-logger';
app.use(mnrReqLogger({
appName: 'my-cool-app',
deploymentEnv: 'production'
}));
What It Does
When process.env.NODE_ENV === 'production'
, mnr-req-logger logs a JSON.stringified object as a single line.
When process.env.NODE_ENV !== 'production'
, mnr-req-logger logs a single line of the following format:
<timestamp> [appName] [deploymentEnv] method url statusCode - responseContentLength - responseTime [transactionId]