Created
March 10, 2021 15:32
-
-
Save gerardoramirez/586f8a79be05c1a83b9f0a3ed90680d8 to your computer and use it in GitHub Desktop.
AWS Lambda Example of Python Logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import json | |
| import logging | |
| logger = logging.getLogger() | |
| handler = logger.handlers[0] | |
| handler = logger.setLevel(logging.INFO) | |
| def lambda_handler(event, context): | |
| logger.info('got an event'.format(event)) | |
| logger.info('This is sample of info 1 of 5') | |
| logger.info('This is sample of info 2 of 5') | |
| logger.info('This is sample of info 3 of 5') | |
| logger.info('This is sample of info 4 of 5') | |
| logger.info('This is sample of info 5 of 5') | |
| logger.error('This is sample of error 1 of 5') | |
| logger.error('This is sample of error 2 of 5') | |
| logger.error('This is sample of error 3 of 5') | |
| return { | |
| 'statusCode': 200, | |
| 'body': json.dumps('Hello from Lambda!') | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment