@map-colonies/express-access-log-middleware
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

express-access-log-middleware

An access and error logger for express based on pino-http

Usage

import * as express from 'express';
import jsLogger from '@map-colonies/js-logger';
import httpLogger from '@map-colonies/express-access-log-middleware';

const app = express()

const logger = jsLogger();

app.use(jsLogger({logger}));

app.get('/', (req,res) => {
  res.json(hello: 'world');
});

app.listen(8080);

for more detailed usage check the pino-http documentation.

Configuration

name type default value description
logger Logger The logger instance to use
ignorePaths string[] undefined The paths to ignore logging
customLogLevel (res, err) => log_level info for all under 500 status A function to set the log level of a request
customSuccessMessage (res: ServerResponse) => string undefined function to set the success message
customErrorMessage (error: Error, res: ServerResponse) => string undefined function to set the success message

Readme

Keywords

none

Package Sidebar

Install

npm i @map-colonies/express-access-log-middleware

Weekly Downloads

49

Version

2.0.1

License

ISC

Unpacked Size

6.91 kB

Total Files

6

Last publish

Collaborators

  • mapcolonies
  • syncush
  • asaf.masa
  • schnitz
  • shahar_s
  • konchashlomicl
  • shimoncohen
  • alebinson
  • rannyeli
  • tropface
  • glata95