Logger output in WebUI (#337)

* expanding logging result array of JSON request

* matching web logging output to console
This commit is contained in:
Paulchen Panther 2016-12-17 22:14:30 +01:00 committed by redPanther
parent cb7e2ff1c0
commit 8aa0fbaa1e
2 changed files with 35 additions and 10 deletions

View File

@ -34,9 +34,21 @@ $(document).ready(function() {
messages = (event.response.result.messages);
for(var idx=0; idx<messages.length; idx++)
{
msg = messages[idx];
$("#logmessages").html($("#logmessages").html()+"\n <code>"+msg+"</code>");
app_name = messages[idx].appName;
logger_name = messages[idx].loggerName;
function_ = messages[idx].function;
line = messages[idx].line;
file_name = messages[idx].fileName;
msg = messages[idx].message;
level_string = messages[idx].levelString;
var debug = "";
if(level_string == "DEBUG") {
debug = "&lt;"+file_name+":"+line+":"+function_+"()&gt; ";
}
$("#logmessages").html($("#logmessages").html()+"\n <code>"+"["+app_name+" "+logger_name+"] &lt;"+level_string+"&gt; "+debug+msg+"</code>");
}
if($("#btn_autoscroll").hasClass('btn-success')){
$('#logmessages').stop().animate({

View File

@ -1257,8 +1257,8 @@ void JsonClientConnection::handleLoggingCommand(const QJsonObject& message, cons
void JsonClientConnection::incommingLogMessage(Logger::T_LOG_MESSAGE msg)
{
QJsonObject result;
QJsonArray messages;
QJsonObject result, message;
QJsonArray messageArray;
if (!_streaming_logging_activated)
{
@ -1266,24 +1266,37 @@ void JsonClientConnection::incommingLogMessage(Logger::T_LOG_MESSAGE msg)
QVector<Logger::T_LOG_MESSAGE>* logBuffer = LoggerManager::getInstance()->getLogMessageBuffer();
for(int i=0; i<logBuffer->length(); i++)
{
//std::cout << "------- " << logBuffer->at(i).message.toStdString() << std::endl;
messages.append(logBuffer->at(i).message);
message["appName"] = logBuffer->at(i).appName;
message["loggerName"] = logBuffer->at(i).loggerName;
message["function"] = logBuffer->at(i).function;
message["line"] = QString::number(logBuffer->at(i).line);
message["fileName"] = logBuffer->at(i).fileName;
message["message"] = logBuffer->at(i).message;
message["levelString"] = logBuffer->at(i).levelString;
messageArray.append(message);
}
}
else
{
//std::cout << "------- " << msg.message.toStdString() << std::endl;
messages.append(msg.message);
message["appName"] = msg.appName;
message["loggerName"] = msg.loggerName;
message["function"] = msg.function;
message["line"] = QString::number(msg.line);
message["fileName"] = msg.fileName;
message["message"] = msg.message;
message["levelString"] = msg.levelString;
messageArray.append(message);
}
result["messages"] = messages;
result.insert("messages", messageArray);
_streaming_logging_reply["result"] = result;
// send the result
sendMessage(_streaming_logging_reply);
}
void JsonClientConnection::handleNotImplemented()
{
sendErrorReply("Command not implemented");