Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@schibsted/middy-access-log

schibsted63MIT4.0.2

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

Lambda, Middleware, Serverless, Framework, AWS, AWS Lambda, Middy, Access log, Logging, bunyan, pino, JSON logger

readme

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.

changelog

4.0.2 (2022-08-29)

Build System

Miscellaneous Chores

  • deps: update dependency @babel/eslint-parser to v7.18.9 (#105) (5c5c313)
  • deps: update dependency @middy/core to v3.1.0 (#107) (41fc0a4)
  • deps: update dependency @middy/core to v3.3.0 (#114) (1a72b32)
  • deps: update dependency eslint to v8.23.0 (#115) (7964699)
  • deps: update dependency jest to v28.1.3 (#108) (6b5dd2a)
  • deps: update dependency jest to v29 (#113) (642a568)
  • deps: update linters (#103) (d58f611)
  • deps: update linters (#106) (7d81c0d)
  • deps: update release-related tools (#104) (a6ec4b0)

4.0.1 (2022-05-19)

Miscellaneous Chores

4.0.0 (2022-05-19)

⚠ BREAKING CHANGES

  • add Node 16 support, drop Node 12

  • config(renovate): remove node version restriction

  • config(github): run tests on correct Node versions

Features

Build System

  • deps: bump minimist from 1.2.5 to 1.2.6 (#98) (cb17767)

Miscellaneous Chores

3.1.0 (2022-03-18)

Features

Bug Fixes

  • deps: update dependency ramda to ^0.28.0 (#70) (1b6de7b)
  • renovate: fix minor issues (#65) (068f6e0)

Configuration changes

  • renovate: enable automerging minor updates (#80) (2425d02)
  • renovate: extend shared preset (6857ec7)

Miscellaneous Chores

  • deps: update actions/checkout action to v3 (#79) (0b20110)
  • deps: update dependency @babel/eslint-parser to v7.17.0 (#73) (3287f74)
  • deps: update dependency @middy/core to v2.5.7 (#71) (1111fd1)
  • deps: update dependency eslint to v8.8.0 (#67) (ce2c4c9)
  • deps: update dependency eslint-plugin-import to v2.25.4 (#68) (c1ef879)
  • deps: update dependency eslint-plugin-jest to v26 (#72) (278dc67)
  • deps: update dependency jest to v27.4.7 (#69) (f90f911)
  • deps: update dependency jest to v27.5.1 (#81) (dfbc086)
  • deps: update dependency lint-staged to v12.3.3 (#66) (f15ed81)
  • deps: update dependency lint-staged to v12.3.4 (#77) (ef59818)
  • deps: update linters (#82) (fa46445)

3.0.0 (2021-12-21)

⚠ BREAKING CHANGES

  • update dependencies (#62)

Documentation

Miscellaneous Chores

2.0.2 (2021-08-12)

Bug Fixes

  • npm publish with husky 7 (bb8732a)

2.0.0 (2021-07-27)

Features

0.3.0 (2021-02-18)

0.2.0 (2020-12-11)

0.1.1 (2020-10-29)

0.1.0 (2020-10-28)

0.0.4 (2020-10-26)

0.0.3 (2020-10-23)

0.0.2 (2020-10-23)

0.0.1 (2020-10-23)