Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 4 files). Show all
Unified · Split
| @@ -40,6 +40,7 @@ · 39 unmodified lines | |||
| 40 | 40 | ||
| 41 | #include <shared/LocalFileAccessGate.h> | 41 | #include <shared/LocalFileAccessGate.h> |
| 42 | #include <shared/QtHelpers.h> | 42 | #include <shared/QtHelpers.h> |
| 43 | #include <shared/AbstractLoggerInterface.h> | ||
| 43 | #include <AudioConstants.h> | 44 | #include <AudioConstants.h> |
| 44 | #include <AudioEffectOptions.h> | 45 | #include <AudioEffectOptions.h> |
| 45 | #include <AvatarData.h> | 46 | #include <AvatarData.h> |
| @@ -78,7 +79,6 @@ · 32 unmodified lines | |||
| 78 | #include "StackTestScriptingInterface.h" | 79 | #include "StackTestScriptingInterface.h" |
| 79 | #include "ModelScriptingInterface.h" | 80 | #include "ModelScriptingInterface.h" |
| 80 | 81 | ||
| 81 | |||
| 82 | #include <Profile.h> | 82 | #include <Profile.h> |
| 83 | 83 | ||
| 84 | #include "../../midi/src/Midi.h" // FIXME why won't a simpler include work? | 84 | #include "../../midi/src/Midi.h" // FIXME why won't a simpler include work? |
| @@ -127,38 +127,45 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { · 42 unmodified lines | |||
| 127 | 127 | ||
| 128 | // This message was sent by one of our script engines, let's try to see if we can find the source. | 128 | // This message was sent by one of our script engines, let's try to see if we can find the source. |
| 129 | // Note that the first entry in the backtrace should be "print" and is somewhat useless to us | 129 | // Note that the first entry in the backtrace should be "print" and is somewhat useless to us |
| 130 | QScriptContext* userContext = context; | 130 | AbstractLoggerInterface* loggerInterface = AbstractLoggerInterface::get(); |
| 131 | while (userContext != nullptr && QScriptContextInfo(userContext).functionType() == QScriptContextInfo::NativeFunction) { | 131 | if (loggerInterface->showSourceDebugging()) { |
| 132 | userContext = userContext->parentContext(); | 132 | QScriptContext* userContext = context; |
| 133 | } | 133 | while (userContext != nullptr && QScriptContextInfo(userContext).functionType() == QScriptContextInfo::NativeFunction) { |
| 134 | QString location; | 134 | userContext = userContext->parentContext(); |
| 135 | if (userContext != nullptr) { | 135 | } |
| 136 | QScriptContextInfo contextInfo(userContext); | 136 | QString location; |
| 137 | QString fileName = contextInfo.fileName(); | 137 | if (userContext != nullptr) { |
| 138 | int lineNumber = contextInfo.lineNumber(); | 138 | QScriptContextInfo contextInfo(userContext); |
| 139 | QString functionName = contextInfo.functionName(); | 139 | QString fileName = contextInfo.fileName(); |
| 140 | 140 | int lineNumber = contextInfo.lineNumber(); | |
| 141 | location = functionName; | 141 | QString functionName = contextInfo.functionName(); |
| 142 | if (lineNumber != -1) { | 142 | |
| 143 | location = QString("%1:%2").arg(location).arg(lineNumber); | 143 | location = functionName; |
| 144 | } | 144 | if (lineNumber != -1) { |
| 145 | if (!fileName.isEmpty()) { | 145 | location = QString("%1:%2").arg(location).arg(lineNumber); |
| 146 | if (location.isEmpty()) { | 146 | } |
| 147 | location = fileName; | 147 | if (!fileName.isEmpty()) { |
| 148 | } else { | 148 | if (location.isEmpty()) { |
| 149 | location = QString("%1 at %2").arg(location).arg(fileName); | 149 | location = fileName; |
| 150 | } else { | ||
| 151 | location = QString("%1 at %2").arg(location).arg(fileName); | ||
| 152 | } | ||
| 150 | } | 153 | } |
| 151 | } | 154 | } |
| 155 | if (location.isEmpty()) { | ||
| 156 | location = scriptEngine->getFilename(); | ||
| 157 | } | ||
| 158 | |||
| 159 | // give the script engine a chance to notify the system about this message | ||
| 160 | scriptEngine->print(message); | ||
| 161 | |||
| 162 | // send the message to debug log | ||
| 163 | qCDebug(scriptengine_script, "[%s] %s", qUtf8Printable(location), qUtf8Printable(message)); | ||
| 164 | } else { | ||
| 165 | scriptEngine->print(message); | ||
| 166 | // prefix the script engine name to help disambiguate messages in the main debug log | ||
| 167 | qCDebug(scriptengine_script, "[%s] %s", qUtf8Printable(scriptEngine->getFilename()), qUtf8Printable(message)); | ||
| 152 | } | 168 | } |
| 153 | if (location.isEmpty()) { | ||
| 154 | location = scriptEngine->getFilename(); | ||
| 155 | } | ||
| 156 | |||
| 157 | // give the script engine a chance to notify the system about this message | ||
| 158 | scriptEngine->print(message); | ||
| 159 | |||
| 160 | // send the message to debug log | ||
| 161 | qCDebug(scriptengine_script, "[%s] %s", qUtf8Printable(location), qUtf8Printable(message)); | ||
| 162 | 169 | ||
| 163 | return QScriptValue(); | 170 | return QScriptValue(); |
| 164 | } | 171 | } |