Logbuffer (#298)

* - implement a global logbuffer
- providerrs232 reduce log spam

* logger add signal and start json push

* implement logger notifier ... need some cleanup

* imlement logview in webui - the layout stuff is basic atm and needs some tuning
This commit is contained in:
redPanther
2016-11-26 22:46:16 +01:00
committed by GitHub
parent 73406c982b
commit 1b62d9d717
13 changed files with 265 additions and 159 deletions

View File

@@ -47,21 +47,17 @@ JsonClientConnection::JsonClientConnection(QTcpSocket *socket)
, _hyperion(Hyperion::getInstance())
, _receiveBuffer()
, _webSocketHandshakeDone(false)
//, _log(Logger::getInstance("JSONCLIENTCONNECTION"))
, _log(Logger::getInstance("JSONCLIENTCONNECTION"))
, _forwarder_enabled(true)
, _streaming_logging_activated(false)
{
_log = Logger::getInstance("JSONCLIENTCONNECTION");
// connect internal signals and slots
connect(_socket, SIGNAL(disconnected()), this, SLOT(socketClosed()));
connect(_socket, SIGNAL(readyRead()), this, SLOT(readData()));
connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool)));
_timer_ledcolors.setSingleShot(false);
connect(&_timer_ledcolors, SIGNAL(timeout()), this, SLOT(streamLedcolorsUpdate()));
//qRegisterMetaType<Logger::T_LOG_MESSAGE>("Logger::T_LOG_MESSAGE");
connect(LoggerNotifier::getInstance(),SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, SLOT(incommingLogMessage(Logger::T_LOG_MESSAGE)));
}
@@ -1224,15 +1220,18 @@ void JsonClientConnection::handleLoggingCommand(const QJsonObject& message, cons
if (!_streaming_logging_activated)
{
_streaming_logging_reply["command"] = command+"-update";
connect(_log,SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, SLOT(incommingLogMessage(Logger::T_LOG_MESSAGE)));
connect(LoggerManager::getInstance(),SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, SLOT(incommingLogMessage(Logger::T_LOG_MESSAGE)));
Debug(_log, "log streaming activated"); // needed to trigger log sending
}
}
else if (subcommand == "stop")
{
if (_streaming_logging_activated)
{
disconnect(_log, SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, 0);
disconnect(LoggerManager::getInstance(), SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, 0);
_streaming_logging_activated = false;
Debug(_log, "log streaming deactivated");
}
}
else
@@ -1246,17 +1245,30 @@ void JsonClientConnection::handleLoggingCommand(const QJsonObject& message, cons
void JsonClientConnection::incommingLogMessage(Logger::T_LOG_MESSAGE msg)
{
QJsonObject result;
QJsonArray messages;
if (!_streaming_logging_activated)
{
_streaming_logging_activated = true;
QVector<Logger::T_LOG_MESSAGE>* logBuffer = Logger::getGlobalLogMessageBuffer();
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;
//std::cout << "------- " << logBuffer->at(i).message.toStdString() << std::endl;
messages.append(logBuffer->at(i).message);
}
}
else
{
//std::cout << "------- " << msg.message.toStdString() << std::endl;
messages.append(msg.message);
}
std::cout << "------- " << msg.message.toStdString() << std::endl;
result["messages"] = messages;
_streaming_logging_reply["result"] = result;
// send the result
sendMessage(_streaming_logging_reply);
}

View File

@@ -17,5 +17,6 @@
<file alias="schema-config">schema/schema-config.json</file>
<file alias="schema-componentstate">schema/schema-componentstate.json</file>
<file alias="schema-ledcolors">schema/schema-ledcolors.json</file>
<file alias="schema-logging">schema/schema-logging.json</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,28 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["logging"]
},
"tan" : {
"type" : "integer"
},
"subcommand": {
"type" : "string",
"required" : true,
"enum" : ["stop","start","update"]
},
"oneshot": {
"type" : "bool"
},
"interval": {
"type" : "integer"
}
},
"additionalProperties": false
}

View File

@@ -5,7 +5,7 @@
"command": {
"type" : "string",
"required" : true,
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect", "config", "componentstate", "ledcolors"]
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging"]
}
}
}