2019-07-26 11:05:27 +01:00
|
|
|
from .spotify import app
|
2019-08-17 18:30:13 +01:00
|
|
|
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger.setLevel('DEBUG')
|
|
|
|
|
2019-09-05 12:20:21 +01:00
|
|
|
spotframework_logger = logging.getLogger('spotframework')
|
|
|
|
|
2019-08-17 18:30:13 +01:00
|
|
|
if os.environ.get('DEPLOY_DESTINATION', None) == 'PROD':
|
|
|
|
from google.cloud import logging as glogging
|
|
|
|
|
|
|
|
log_format = '%(funcName)s - %(message)s'
|
|
|
|
formatter = logging.Formatter(log_format)
|
|
|
|
|
|
|
|
client = glogging.Client()
|
2019-08-18 09:43:48 +01:00
|
|
|
handler = client.get_default_handler()
|
2019-08-17 18:30:13 +01:00
|
|
|
|
|
|
|
handler.setFormatter(formatter)
|
|
|
|
|
|
|
|
logger.addHandler(handler)
|
2019-09-05 12:20:21 +01:00
|
|
|
spotframework_logger.addHandler(handler)
|
2019-08-17 18:30:13 +01:00
|
|
|
|
|
|
|
else:
|
|
|
|
log_format = '%(levelname)s %(name)s:%(funcName)s - %(message)s'
|
|
|
|
formatter = logging.Formatter(log_format)
|
|
|
|
|
|
|
|
stream_handler = logging.StreamHandler()
|
|
|
|
stream_handler.setFormatter(formatter)
|
|
|
|
|
|
|
|
logger.addHandler(stream_handler)
|
2019-09-05 12:20:21 +01:00
|
|
|
spotframework_logger.addHandler(stream_handler)
|