Bug fixes. Adjust logger

This commit is contained in:
Khanh Ngo 2019-12-10 17:08:43 +07:00
parent 9904505867
commit 67e6df6880
No known key found for this signature in database
GPG Key ID: D5FAA6A16150E49E
3 changed files with 22 additions and 9 deletions

View File

@ -1,7 +1,8 @@
import os import os
from werkzeug.middleware.proxy_fix import ProxyFix import logging
from flask import Flask from flask import Flask
from flask_seasurf import SeaSurf from flask_seasurf import SeaSurf
from werkzeug.middleware.proxy_fix import ProxyFix
from .lib import utils from .lib import utils
@ -11,6 +12,18 @@ def create_app(config=None):
from .assets import assets from .assets import assets
app = Flask(__name__) 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 # Proxy
app.wsgi_app = ProxyFix(app.wsgi_app) app.wsgi_app = ProxyFix(app.wsgi_app)

View File

@ -125,7 +125,8 @@ class Record(object):
"content": self.data, "content": self.data,
"disabled": self.status, "disabled": self.status,
}], }],
"comments": [self.comment_data] "comments":
[self.comment_data] if self.comment_data else []
}] }]
} }
else: else:
@ -144,7 +145,8 @@ class Record(object):
"ttl": self.ttl, "ttl": self.ttl,
"type": self.type "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} postdata_for_new = {"rrsets": final_records}
current_app.logger.debug(postdata_for_new) current_app.logger.debug(
current_app.logger.debug(postdata_for_delete) "postdata_for_new: {}".format(postdata_for_new))
current_app.logger.debug(
"postdata_for_delete: {}".format(postdata_for_delete))
current_app.logger.info( current_app.logger.info(
urljoin( urljoin(
self.PDNS_STATS_URL, self.API_EXTENDED_URL + self.PDNS_STATS_URL, self.API_EXTENDED_URL +

View File

@ -21,10 +21,6 @@ function applyChanges(data, url, showResult, refreshPage) {
}, },
error : function(jqXHR, status) { 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); console.log(jqXHR);
var modal = $("#modal_error"); var modal = $("#modal_error");
var responseJson = jQuery.parseJSON(jqXHR.responseText); var responseJson = jQuery.parseJSON(jqXHR.responseText);