Skip to main content.

Debug LogsEnable and disable debug logs to reduce noise.


When writing code, it's a good practice to log as much as you can that would help you debug an issue in an environment where you do not have direct access, such as AWS Lambda. LambdaLog provides a debug log level which you can use to log verbose information within your process. These debug logs will not be logged to the console unless you enable the debug configuration option in LambdaLog, allowing you to keep the noise to a minimum but also have the ability to enable the logs for debugging purposes.

This feature will be DEPRECATED in the next major version and replaced with a log level verbosity setting instead. You may continue to use this feature until the next version of LambdaLog is released.

Writing Debug Logs

Similar to other log levels, you can use the specified method to log a debug message. These logs will not be written to the console unless the debug configuration option is enabled.

1const log = require('lambda-log');
3log.debug('This is a debug message');
4// => false
6// Enable debug mode
7log.options.debug = true;
9log.debug('It can take all the same options as a regular log', { suchAs: 'the metadata object' }, ['and', 'tags'])
10// => { "_logLevel": "debug", "msg": "It can take all the same options as a regular log", "suchAs": "the metadata object", "_tags": ["and", "tags"] }
12// Disable debug mode
13log.options.debug = false;
15// Using the standard log method
16log.log('debug', 'Example debug message');
17// => false

Enabling Debug Logs

Depending on how you are implementing LambdaLog into your project, you can enable this option easily and at any time.

1const log = require('lambda-log');
3// Enable debug logs
4log.options.debug = true;
1const { LambdaLog } = require('lambda-log');
3const log = new LambdaLog({
4 // Enable debug logs
5 debug: true
8// You can still disable it later in your process with:
9log.options.debug = false;