Socket
Book a DemoInstallSign in
Socket

@schibsted/middy-access-log

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@schibsted/middy-access-log

Middy middleware for logging processed requests in an access-log like fashion. Optimised for JSON loggers e.g. Bunyan or Pino.

latest
Source
npmnpm
Version
4.0.2
Version published
Weekly downloads
21
2000%
Maintainers
5
Weekly downloads
 
Created
Source

Middy access log middleware

github checks current version @ npm weekly downloads @ npm minified size

Access log middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

This middleware logs processed requests in an access log like fashion. I suggest using it together with @schibsted/middy-error-handler

This access log is optimised for JSON loggers e.g. bunyan or pino

Sets headers in after and onError phases.

Install

To install this middleware you can use NPM:

npm install --save @schibsted/middy-access-log

Options

  • logger (defaults to console) - a logging function that is invoked with the current error as an argument. You can pass false if you don't want the logging to happen.
  • level (defaults to info) - log level to use for the log entries
  • excludeHeaders (array of header names, defaults to []) - prevent specified headers from showing up in logs (e.g. user credentials)

See the sample usage below.

Sample usage

const middy = require('@middy/core');
const accessLog = require('@schibsted/middy-access-log');
const bunyan = require('bunyan');
const logger = bunyan.createLogger({name: "myapp"});

const handler = middy(async () => ({
        statusCode: 200,
        body: JSON.stringify({ foo: 'bar' }),
    }));

handler
  .use(accessLog({ logger }));

Contributing

Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.

Keywords

Lambda

FAQs

Package last updated on 29 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts