diff --git a/api/utils.py b/api/utils.py index a6e780e6..591a8233 100644 --- a/api/utils.py +++ b/api/utils.py @@ -2,12 +2,12 @@ import json import os import numpy as np -import requests -import ring +import requests, ring, logging from decouple import config from api.models import Order +logger = logging.getLogger('api.utils') def get_tor_session(): session = requests.session() @@ -52,7 +52,8 @@ def validate_onchain_address(address): validation = bitcoind_rpc('validateaddress', [address]) if not validation['isvalid']: return False, {"bad_address": "Invalid address"} - except: + except Exception as e: + logger.error(e) return False, {"bad_address": 'Unable to validate address, check bitcoind backend'} return True, None diff --git a/robosats/settings.py b/robosats/settings.py index 8390d756..324df45d 100644 --- a/robosats/settings.py +++ b/robosats/settings.py @@ -29,6 +29,7 @@ DEBUG = False STATIC_URL = "static/" STATIC_ROOT = "/usr/src/static/" + # SECURITY WARNING: don't run with debug turned on in production! if os.environ.get("DEVELOPMENT"): DEBUG = True @@ -48,6 +49,28 @@ ALLOWED_HOSTS = [ # Allows Session Cookie to be read by Javascript on Client side. SESSION_COOKIE_HTTPONLY = False +# Logging settings +if os.environ.get("LOG_TO_CONSOLE"): + LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + }, + }, + 'root': { + 'handlers': ['console'], + 'level': 'WARNING', + }, + 'loggers': { + 'api.utils': { + 'handlers': ['console'], + 'level': 'WARNING', + }, + }, + } + # Application definition INSTALLED_APPS = [