Skip to content

waleedsamy/exwml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-logger

Logger utils and middleware build upon winstonjs, severity levels is syslog based.

Build Status

Test

$ npm test

configuration

  • process.env.LOG_FORMAT e.g pretty to generate human readable logs
  • process.env.LOG_LEVEL e.g debug, default is info or debug based on your NODE_ENV
  • process.env.LOG_SUPPRESS with value true to suppress all logs (when you run some test, maybe)

Usage

  • logger object is available globally, and it provide syslog levels { emerg: 0, alert: 1, crit: 2, error: 3, warning: 4, notice: 5, info: 6, debug: 7 }.

  • middleware

    • XRequestId()

      express req.id will be read from req.headers['x-request-id'] and concatenated with the package name or new one is created for this request, and it will be available in request response headers as x-request-id.

      var XRequestId      = require('exwml').XRequestId;
      var app = express();
      app.use(XRequestId());
    • expressWinston()

      log all details about any incoming request such as headers, params, responseTime ...

      var expressWinston      = require('exwml').expressWinston;
      var app = express();
      app.use(expressWinston());

security

  • meta object keys (case insensitive) ['password', 'pwd', 'auth', 'authorization', 'cfg'] will be REDACTED