Skip to content

Commit

Permalink
Merge pull request #1029 from overte-org/fix/entity_server_log
Browse files Browse the repository at this point in the history
Fix long messages in Entity script log
  • Loading branch information
daleglass authored Jun 22, 2024
2 parents 6d20b5a + d0a7520 commit a1e7f7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
17 changes: 16 additions & 1 deletion libraries/entities/src/EntityScriptServerLogClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions libraries/script-engine/src/ScriptEngines.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ScriptEngines : public QObject, public Dependency, public ScriptInitialize
* 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.
Expand All @@ -280,7 +280,7 @@ class ScriptEngines : public QObject, public Dependency, public ScriptInitialize
/*@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.
Expand All @@ -292,7 +292,7 @@ class ScriptEngines : public QObject, public Dependency, public ScriptInitialize

/*@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.
Expand All @@ -304,7 +304,7 @@ class ScriptEngines : public QObject, public Dependency, public ScriptInitialize

/*@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.
Expand Down

0 comments on commit a1e7f7a

Please sign in to comment.