diff --git a/TsaApi/local_settings_dev.py b/TsaApi/local_settings_dev.py index 7a37026a0b8d0693804345f56dc73fb10ccdccb2..100544d0e0b7bef45206694815634b4fdab1a831 100644 --- a/TsaApi/local_settings_dev.py +++ b/TsaApi/local_settings_dev.py @@ -9,6 +9,8 @@ You should have received a copy of the GNU General Public License along with thi """ APP_ROOT = '/opt/project/' +LOG_ROOT = APP_ROOT + 'logs/' + STATIC_ROOT = APP_ROOT + 'html/' ACCOUNT_ADDRESS = '0x25c185dcaed065bac30a0a1cd0688a7aa02896d7' diff --git a/TsaApi/settings.py b/TsaApi/settings.py index 7b4aa3202dc3dce1dee9f362ff2af74b4274f18e..b34187e28c258d435ab866e27007c0dda91bf5b5 100644 --- a/TsaApi/settings.py +++ b/TsaApi/settings.py @@ -8,6 +8,8 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ """ # -*- coding: utf-8 -*- +import sys + """ Django settings for TsaApi project. @@ -51,7 +53,7 @@ INSTALLED_APPS = [ 'raven.contrib.django.raven_compat', 'corsheaders', 'rest_framework_swagger', - 'elasticapm.contrib.django' + 'elasticapm.contrib.django', 'app' ] @@ -157,6 +159,9 @@ REST_FRAMEWORK = { ), } +APP_ROOT = '/var/www/tsaapi.prod.bfa.local/' +LOG_ROOT = APP_ROOT + 'logs/' + SENTRY_URL = 'http://2ec54beaab3b4459a1e5afadea070f98:92aee3f5d91e4e66996a3e0792985541@172.17.30.21:9000/54' MEMCACHED_HOST = '' @@ -169,36 +174,76 @@ TEST_MEMCACHED_PORT = '' TEST_PENDING_TXS_MEMCACHED_KEY = 'test_pending_txs' +ELASTIC_APM = { + 'SERVICE_NAME': 'TsaApi', + 'SERVER_URL': 'http://10.1.100.67:8200', + 'DEBUG': False, +} + +try: + from TsaApi.local_settings import * +except ImportError as e: + pass + +RAVEN_CONFIG = { + 'dsn': SENTRY_URL, +} + LOGGING = { 'version': 1, 'disable_existing_loggers': False, + 'formatters': { + 'detailed': { + 'format': '%(levelname)s %(asctime)s %(filename)s %(funcName)s %(lineno)d %(message)s', + }, + 'history': { + 'format': '%(asctime)s %(message)s' + } + }, 'handlers': { - 'file': { + 'console': { 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'stream': sys.stdout, + 'formatter': 'detailed' + }, + 'info_file': { + 'level': 'INFO', 'class': 'logging.FileHandler', - 'filename': '/path/to/django/debug.log', + 'filename': LOG_ROOT + 'info.log', + 'formatter': 'history', }, + 'error_file': { + 'level': 'ERROR', + 'class': 'logging.FileHandler', + 'filename': LOG_ROOT + 'error.log', + 'formatter': 'detailed', + }, + 'sentry': { + 'level': 'ERROR', # To capture more than ERROR, change to WARNING, INFO, etc. + 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', + } }, 'loggers': { 'django': { - 'handlers': ['file'], - 'level': 'DEBUG', + 'handlers': ['error_file', 'info_file', 'sentry'], + 'level': 'WARNING', + 'propagate': True, + }, + 'raven': { + 'level': 'WARNING', + 'handlers': ['sentry'], + 'propagate': False, + }, + 'logger': { + 'handlers': ['error_file', 'info_file', 'sentry'], + 'level': 'ERROR', 'propagate': True, }, + 'console-logger': { + 'handlers': ['console', 'info_file', 'error_file', 'sentry'], + 'progagate': True, + 'level': 'DEBUG' + } }, } - -ELASTIC_APM = { - 'SERVICE_NAME' : 'TsaApi', - 'SERVER_URL': 'http://10.1.100.67:8200', - 'DEBUG': False, -} - -try: - from TsaApi.local_settings import * -except ImportError as e: - pass - -RAVEN_CONFIG = { - 'dsn': SENTRY_URL, -}