"""Configuration for DynamoDB Streams handler.""" import os import logging import sys import sentry_sdk from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration from sentry_sdk.integrations.logging import LoggingIntegration DEV_ENVIRONMENT = 'dev' TEST_ENVIRONMENT = 'test' PROD_ENVIRONMENT = 'prod' QA_ENVIRONMENT = 'qa' ENVIRONMENT = os.environ.get('Environment', DEV_ENVIRONMENT) # Name of the lambda that handles each VO, saves to direct delivery. VO_TO_DD_SYNC_LAMBDA_NAME = os.environ.get('VO_TO_DD_SYNC_LAMBDA_NAME') # Logger configuration. LOGGER_LEVEL = getattr(logging, os.environ.get('LOGGER_LEVEL', 'INFO')) logger = logging.getLogger() logger.setLevel(LOGGER_LEVEL) stream_handler = logging.StreamHandler(sys.stdout) stream_handler.setLevel(logging.DEBUG) logger.addHandler(stream_handler) # Sentry Config SENTRY_DSN = os.environ.get('SENTRY_DSN') or None if SENTRY_DSN: sentry_sdk.init( dsn=SENTRY_DSN, environment=ENVIRONMENT, integrations=[ LoggingIntegration( level=LOGGER_LEVEL, event_level=None # Don't send error log as sentry event. ), AwsLambdaIntegration() ])