Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gerardoramirez/586f8a79be05c1a83b9f0a3ed90680d8 to your computer and use it in GitHub Desktop.

Select an option

Save gerardoramirez/586f8a79be05c1a83b9f0a3ed90680d8 to your computer and use it in GitHub Desktop.
AWS Lambda Example of Python Logging
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