@miraclesoft/http-logger

0.0.6 • Public • Published

@miraclesoft/http-logger

version license

Morgan and Winston based http logger with predefined settings for prod and non-prod environments.

Note: This is a beta version of this module created for internal use by Miracle Apps, Miracle Software Systems, Inc.'s internal app development wing. Please submit any issues (or) feedback here.

Usage

Install the logger as a dependency.

npm install --save @miraclesoft/http-logger

You can then use the logger in your project as follows,

const logger = require('@miraclesoft/logger');
const httpLogger = require('@miraclesoft/http-logger');
const express = require('express');

const app = express();

app.use(httpLogger);

app.get('/example', (req, res) => {
  res.status(200).send('Here you go!');
});

app.listen(3000, () => {
  logger.info('Server Started');
});

Configuration

The logger uses environment variables for configuration.

If NODE_ENV=production, then logs are logged to a daily rotate log file with the log level set to warn and above. For all other environments, the log level is set info and are logged out to console.

Log files in production are named as app-logs-date.log. You can change this to APP_NAME-date.log by setting the APP_NAME environment variable.

By default the logger(in production) stores 14 days of logs. This can be overridden by setting the MAX_LOG_FILES environment variable.

Contributors

  • Chanakya Lokam - Director Innovation | Miracle Software Systems, Inc.

License

© 2020 Miracle Software Systems, Inc.

Licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @miraclesoft/http-logger

Weekly Downloads

41

Version

0.0.6

License

MIT

Unpacked Size

5.98 kB

Total Files

6

Last publish

Collaborators

  • sbendalam
  • clokam