Last active
December 1, 2018 18:56
-
-
Save pcolazurdo/3426b4c3de02679490f150047f44a802 to your computer and use it in GitHub Desktop.
Lambda Logger Setup Snippet
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 logging | |
import os | |
import boto3 | |
_log_levels = { | |
'CRITICAL': logging.CRITICAL, | |
'ERROR': logging.ERROR, | |
'WARNING': logging.WARNING, | |
'INFO': logging.INFO, | |
'DEBUG': logging.DEBUG | |
} | |
try: | |
_log_level = _log_levels[os.environ['LOG_LEVEL']] | |
except: | |
_log_level = logging.WARNING | |
pass | |
logger = logging.getLogger() | |
logger.setLevel(_log_level) | |
logging.getLogger('boto3').setLevel(logging.WARNING) | |
logging.getLogger('botocore').setLevel(logging.WARNING) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment