Fix getClientLogs function and log viewer on dashboard

This commit is contained in:
Ben Gräf 2018-07-27 21:21:33 +02:00
parent 59d9c7cab1
commit 9380880b58
2 changed files with 6 additions and 7 deletions

View file

@ -416,10 +416,10 @@
type: "GET", type: "GET",
url: "/admin/getClientLog?clientId=" + clientId, url: "/admin/getClientLog?clientId=" + clientId,
dataType:"json", dataType:"json",
success: function(jsonClientLog) { success: function(data) {
var htmlContent = "<div class='form-group' id='viewer' data-value='" + clientId + "'>" + var htmlContent = "<div class='form-group' id='viewer' data-value='" + clientId + "'>" +
"<label for='config'>Log of: " + clientId + " (" + clientIp + ")</label>"+ "<label for='config'>Log of: " + clientId + " (" + clientIp + ")</label>"+
"<textarea class='form-control' rows='20' id='log'>" + JSON.stringify(jsonClientLog,undefined, 2) + "</textarea>" + "<textarea class='form-control' rows='20' id='log'>" + data.client_log + "</textarea>" +
"</div>"; "</div>";
$('#minerLog').find('.modal-body').html(htmlContent); $('#minerLog').find('.modal-body').html(htmlContent);
@ -442,8 +442,8 @@
type: "GET", type: "GET",
url: "/admin/getClientLog?clientId=" + clientId, url: "/admin/getClientLog?clientId=" + clientId,
dataType:"json", dataType:"json",
success: function(jsonClientLog) { success: function(data) {
$('#log').val(JSON.stringify(jsonClientLog,undefined, 2)); $('#log').val(data.client_log);
}, },
error: function (data) { error: function (data) {
setError('<strong>Unable to fetch ' + clientId + ' log.</strong> - Please make sure it is enabled on the miner!'); setError('<strong>Unable to fetch ' + clientId + ' log.</strong> - Please make sure it is enabled on the miner!');

View file

@ -288,9 +288,8 @@ unsigned Service::getClientLog(const std::string& clientId, std::string& resp)
data << m_row.c_str() << std::endl; data << m_row.c_str() << std::endl;
} }
LOG_INFO("LOG: %s", data.str().c_str()); std::string log = data.str();
respDocument.AddMember("client_log", rapidjson::StringRef(log.c_str()), allocator);
respDocument.AddMember("client_log", rapidjson::StringRef(data.str().c_str()), allocator);
rapidjson::StringBuffer buffer(0, 4096); rapidjson::StringBuffer buffer(0, 4096);
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);