Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

middy-console-logger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

middy-console-logger

Middy AWS Lambda console logger middleware

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

middy-console-logger

Middy middleware for filtering logs printed over console logging methods (trace, debug, info, log, warn, error). If the level of the console logging method is equal or bigger than configured level, the log is printed, Otherwise, it is ignored.

You can find the supported log levels and their orders in the following table:

Log Level NameLog Level
NONE0
TRACE1
DEBUG2
INFO3
LOG3
WARN4
ERROR5

Note: The default log level is NONE and which means that all the logs are printed by default if you don't configure any log level threshold.

Installation

To install the middleware, you can use NPM:

npm install --save middy-console-logger

Note: Requires @middy/core version 2.0.0+

Usage

  • Register middy-console-logger middleware in your handler:
const middy = require('@middy/core');
const consoleLogger = require('middy-console-logger');

const handler = async(event, context) => {
  // Do something meaningful

  return {
    statusCode: 200,
  }
}

module.exports.handler = middy(handler).use(consoleLogger());
  • Configure log level by environment variable or options passed to middleware:

    • By environment variable: Set MIDDY_CL_LOG_LEVEL environment variable to any supported log level.
    MIDDY_CL_LOG_LEVEL=INFO
    
    • By options: Pass the log level through options.
    const consoleLogger = require('middy-console-logger');
    
    module.exports.handler = middy(handler).use(consoleLogger({logLevel: 'INFO'}));
    

Contributing

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

License

Licensed under MIT License.

Keywords

middy

FAQs

Package last updated on 29 Nov 2021

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