Merge pull request #1029 from overte-org/fix/entity_server_log

Fix long messages in Entity script log
This commit is contained in:
Dale Glass 2024-06-22 21:38:22 +02:00 committed by GitHub
commit a1e7f7a03e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View file

@ -69,7 +69,6 @@ void EntityScriptServerLogClient::handleEntityServerScriptLogPacket(QSharedPoint
QString messageText = QString::fromUtf8(message->readAll());
QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(messageText.toUtf8(), &error);
emit receivedNewLogLines(messageText);
if(document.isNull()) {
qWarning() << "EntityScriptServerLogClient::handleEntityServerScriptLogPacket: Cannot parse JSON: " << error.errorString()
<< " Contents: " << messageText;
@ -98,21 +97,37 @@ void EntityScriptServerLogClient::handleEntityServerScriptLogPacket(QSharedPoint
case ScriptMessage::Severity::SEVERITY_INFO:
emit scriptEngines->infoEntityMessage(scriptMessage.getMessage(), scriptMessage.getFileName(),
scriptMessage.getLineNumber(), scriptMessage.getEntityID(), true);
emit receivedNewLogLines("[ INFO {" + scriptMessage.getEntityID().toString() + "} "
+ scriptMessage.getFileName() + ":"
+ QString::number(scriptMessage.getLineNumber()) + "] "
+ scriptMessage.getMessage());
break;
case ScriptMessage::Severity::SEVERITY_PRINT:
emit scriptEngines->printedEntityMessage(scriptMessage.getMessage(), scriptMessage.getFileName(),
scriptMessage.getLineNumber(), scriptMessage.getEntityID(), true);
emit receivedNewLogLines("[ WARNING {" + scriptMessage.getEntityID().toString() + "} "
+ scriptMessage.getFileName() + ":"
+ QString::number(scriptMessage.getLineNumber()) + "] "
+ scriptMessage.getMessage());
break;
case ScriptMessage::Severity::SEVERITY_WARNING:
emit scriptEngines->warningEntityMessage(scriptMessage.getMessage(), scriptMessage.getFileName(),
scriptMessage.getLineNumber(), scriptMessage.getEntityID(), true);
emit receivedNewLogLines("[ WARNING {" + scriptMessage.getEntityID().toString() + "} "
+ scriptMessage.getFileName() + ":"
+ QString::number(scriptMessage.getLineNumber()) + "] "
+ scriptMessage.getMessage());
break;
case ScriptMessage::Severity::SEVERITY_ERROR:
emit scriptEngines->errorEntityMessage(scriptMessage.getMessage(), scriptMessage.getFileName(),
scriptMessage.getLineNumber(), scriptMessage.getEntityID(), true);
emit receivedNewLogLines("[ ERROR {" + scriptMessage.getEntityID().toString() + "} "
+ scriptMessage.getFileName() + ":"
+ QString::number(scriptMessage.getLineNumber()) + "] "
+ scriptMessage.getMessage());
break;
default:

View file

@ -267,7 +267,7 @@ signals:
* Triggered when a client side entity script prints a message to the program log via {@link print}, {@link Script.print},
* {@link console.log}, {@link console.debug}, {@link console.group}, {@link console.groupEnd}, {@link console.time}, or
* {@link console.timeEnd}.
* @function Script.printedMessage
* @function Script.printedEntityMessage
* @param {string} message - The message.
* @param {string} fileName - Name of the file in which message was generated. Empty string when no file name is available.
* @param {number} lineNumber - Number of the line on which message was generated. -1 if there line number is not available.
@ -280,7 +280,7 @@ signals:
/*@jsdoc
* Triggered when a client side entity script generates an error, {@link console.error} or {@link console.exception} is called, or
* {@link console.assert} is called and fails.
* @function Script.errorMessage
* @function Script.errorEntityMessage
* @param {string} message - The error message.
* @param {string} fileName - Name of the file in which message was generated. Empty string when no file name is available.
* @param {number} lineNumber - Number of the line on which message was generated. -1 if there line number is not available.
@ -292,7 +292,7 @@ signals:
/*@jsdoc
* Triggered when a client side entity script generates a warning or {@link console.warn} is called.
* @function Script.warningMessage
* @function Script.warningEntityMessage
* @param {string} message - The warning message.
* @param {string} fileName - Name of the file in which message was generated. Empty string when no file name is available.
* @param {number} lineNumber - Number of the line on which message was generated. -1 if there line number is not available.
@ -304,7 +304,7 @@ signals:
/*@jsdoc
* Triggered when a client side entity script generates an information message or {@link console.info} is called.
* @function Script.infoMessage
* @function Script.infoEntityMessage
* @param {string} message - The information message.
* @param {string} fileName - Name of the file in which message was generated. Empty string when no file name is available.
* @param {number} lineNumber - Number of the line on which message was generated. -1 if there line number is not available.