diff --git a/powerdnsadmin/__init__.py b/powerdnsadmin/__init__.py index 38c82ff..2f2c977 100755 --- a/powerdnsadmin/__init__.py +++ b/powerdnsadmin/__init__.py @@ -1,7 +1,8 @@ import os -from werkzeug.middleware.proxy_fix import ProxyFix +import logging from flask import Flask from flask_seasurf import SeaSurf +from werkzeug.middleware.proxy_fix import ProxyFix from .lib import utils @@ -11,6 +12,18 @@ def create_app(config=None): from .assets import assets app = Flask(__name__) + # Setting logger + logging.basicConfig( + format= + "[%(asctime)s] [%(filename)s:%(lineno)d] %(levelname)s - %(message)s") + + # If we use Docker + Gunicorn, adjust the + # log handler + if "GUNICORN_LOGLEVEL" in os.environ: + gunicorn_logger = logging.getLogger("gunicorn.error") + app.logger.handlers = gunicorn_logger.handlers + app.logger.setLevel(gunicorn_logger.level) + # Proxy app.wsgi_app = ProxyFix(app.wsgi_app) diff --git a/powerdnsadmin/models/record.py b/powerdnsadmin/models/record.py index 1b6355c..4364793 100644 --- a/powerdnsadmin/models/record.py +++ b/powerdnsadmin/models/record.py @@ -125,7 +125,8 @@ class Record(object): "content": self.data, "disabled": self.status, }], - "comments": [self.comment_data] + "comments": + [self.comment_data] if self.comment_data else [] }] } else: @@ -144,7 +145,8 @@ class Record(object): "ttl": self.ttl, "type": self.type }], - "comments": [self.comment_data] + "comments": + [self.comment_data] if self.comment_data else [] }] } @@ -367,8 +369,10 @@ class Record(object): }) postdata_for_new = {"rrsets": final_records} - current_app.logger.debug(postdata_for_new) - current_app.logger.debug(postdata_for_delete) + current_app.logger.debug( + "postdata_for_new: {}".format(postdata_for_new)) + current_app.logger.debug( + "postdata_for_delete: {}".format(postdata_for_delete)) current_app.logger.info( urljoin( self.PDNS_STATS_URL, self.API_EXTENDED_URL + diff --git a/powerdnsadmin/static/custom/js/custom.js b/powerdnsadmin/static/custom/js/custom.js index d9ad202..df4d434 100644 --- a/powerdnsadmin/static/custom/js/custom.js +++ b/powerdnsadmin/static/custom/js/custom.js @@ -21,10 +21,6 @@ function applyChanges(data, url, showResult, refreshPage) { }, error : function(jqXHR, status) { - // console.log(jqXHR); - // var modal = $("#modal_error"); - // modal.find('.modal-body p').text(jqXHR["responseText"]); - // modal.modal('show'); console.log(jqXHR); var modal = $("#modal_error"); var responseJson = jQuery.parseJSON(jqXHR.responseText);