-
How would I go about showing the function name AWS_LAMBDA_FUNCTION_NAME in each log message? |
Beta Was this translation helpful? Give feedback.
Answered by
KyleRoss
Oct 8, 2021
Replies: 2 comments
-
You can add it as part of your global metadata. Here's an example: const log = require('lambda-log');
exports.handler = async function(event, context) {
log.options.meta = {
functionName: context.functionName
};
log.info('Test log');
// => { "level": "info", "msg": "Test log", "functionName": "my-lambda-function", "_tags": [] }
}; Setting it within the global metadata will add the function name to every log automatically! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
KyleRoss
-
Thank you! Actually I'm doing something like:
But the context object is a bit heavy weight!! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add it as part of your global metadata. Here's an example:
Setting it within the global metadata will add the function name to every log automatically!