Enable warnings logging to console via envvar

This commit is contained in:
Reckless_Satoshi 2022-08-01 05:55:43 -07:00
parent f0cde287e1
commit 6f1e865a15
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 27 additions and 3 deletions

View File

@ -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

View File

@ -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 = [