Rename logging category to overte Make all V8 code use logging categories
Showing the changes to libraries/script-engine/src/v8/ScriptValueV8Wrapper.cpp (1 of 10 files). Show all
Unified · Split
| @@ -17,7 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include "ScriptValueIteratorV8Wrapper.h" |
| 18 | 18 | |
| 19 | 19 | #include "../ScriptEngineLogging.h" |
| 20 | − | |
| 20 | +#include "ScriptEngineLoggingV8.h" | |
| 21 | 21 | |
| 22 | 22 | void ScriptValueV8Wrapper::release() { |
| 23 | 23 | // V8TODO: maybe add an assert to check if it happens on script engine thread? |
| @@ -92,17 +92,17 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 68 unmodified lines | ||
| 92 | 92 | v8::Local<v8::Value> recv; |
| 93 | 93 | if (v8This.get()->IsObject()) { |
| 94 | 94 | recv = v8This.get(); |
| 95 | − //qDebug() << "V8 This: " << _engine->scriptValueDebugDetailsV8(v8This); | |
| 95 | + //qCDebug(scriptengine_v8) << "V8 This: " << _engine->scriptValueDebugDetailsV8(v8This); | |
| 96 | 96 | }else{ |
| 97 | 97 | recv = _engine->getContext()->Global(); |
| 98 | 98 | //recv = v8::Null(isolate); |
| 99 | − //qDebug() << "global"; | |
| 99 | + //qCDebug(scriptengine_v8) << "global"; | |
| 100 | 100 | } |
| 101 | − //qDebug() << "V8 Call: " << *v8::String::Utf8Value(isolate, v8This.get()->TypeOf(isolate)); | |
| 101 | + //qCDebug(scriptengine_v8) << "V8 Call: " << *v8::String::Utf8Value(isolate, v8This.get()->TypeOf(isolate)); | |
| 102 | 102 | auto maybeResult = v8Function->Call(_engine->getContext(), recv, args.length(), v8Args); |
| 103 | 103 | // V8TODO: Exceptions don't seem to actually be caught here? |
| 104 | 104 | if (tryCatch.HasCaught()) { |
| 105 | − qCDebug(scriptengine) << "Function call failed: \"" << _engine->formatErrorMessageFromTryCatch(tryCatch); | |
| 105 | + qCDebug(scriptengine_v8) << "Function call failed: \"" << _engine->formatErrorMessageFromTryCatch(tryCatch); | |
| 106 | 106 | } |
| 107 | 107 | v8::Local<v8::Value> result; |
| 108 | 108 | Q_ASSERT(_engine == _value.getEngine()); |
| @@ -110,7 +110,7 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 1 unmodified line | ||
| 110 | 110 | return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, result))); |
| 111 | 111 | } else { |
| 112 | 112 | //V8TODO Add more details |
| 113 | − qWarning("JS function call failed"); | |
| 113 | + qCWarning(scriptengine_v8) << "JS function call failed"; | |
| 114 | 114 | return _engine->undefinedValue(); |
| 115 | 115 | } |
| 116 | 116 | } |
| @@ -135,7 +135,7 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 18 unmodified lines | ||
| 135 | 135 | return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine->getContext(), result))); |
| 136 | 136 | } else { |
| 137 | 137 | //V8TODO Add more details |
| 138 | − qWarning("JS function call failed"); | |
| 138 | + qCWarning(scriptengine_v8) << "JS function call failed"; | |
| 139 | 139 | return _engine->undefinedValue(); |
| 140 | 140 | }*/ |
| 141 | 141 | } |
| @@ -163,7 +163,7 @@ ScriptValue ScriptValueV8Wrapper::construct(const ScriptValueList& args) { · 21 unmodified lines | ||
| 163 | 163 | return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, result))); |
| 164 | 164 | } else { |
| 165 | 165 | //V8TODO Add more details |
| 166 | − qWarning("JS function call failed"); | |
| 166 | + qCWarning(scriptengine_v8) << "JS function call failed"; | |
| 167 | 167 | return _engine->undefinedValue(); |
| 168 | 168 | } |
| 169 | 169 | } |
| @@ -205,18 +205,18 @@ ScriptValue ScriptValueV8Wrapper::data() const { · 35 unmodified lines | ||
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | if (createData) { |
| 208 | − qDebug() << "ScriptValueV8Wrapper::data(): Data object doesn't exist, creating new one"; | |
| 208 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::data(): Data object doesn't exist, creating new one"; | |
| 209 | 209 | // Create data object if it's non-existent or invalid |
| 210 | 210 | data = v8::Object::New(isolate); |
| 211 | 211 | if( !v8Object->Set(_engine->getContext(), v8::String::NewFromUtf8(isolate, "__data").ToLocalChecked(), data).FromMaybe(false)) { |
| 212 | − qDebug() << "ScriptValueV8Wrapper::data(): Data object couldn't be created"; | |
| 212 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::data(): Data object couldn't be created"; | |
| 213 | 213 | Q_ASSERT(false); |
| 214 | 214 | } |
| 215 | 215 | }*/ |
| 216 | 216 | V8ScriptValue result(_engine, data); |
| 217 | 217 | return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result))); |
| 218 | 218 | } else { |
| 219 | − qDebug() << "ScriptValueV8Wrapper::data() was called on a value that is not an object"; | |
| 219 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::data() was called on a value that is not an object"; | |
| 220 | 220 | Q_ASSERT(false); |
| 221 | 221 | } |
| 222 | 222 | //V8TODO I'm not sure how this would work in V8 |
| @@ -290,15 +290,15 @@ ScriptValue ScriptValueV8Wrapper::property(const QString& name, const ScriptValu · 67 unmodified lines | ||
| 290 | 290 | if (_value.constGet()->ToDetailString(_engine->getContext()).ToLocal(&parentValueString)) { |
| 291 | 291 | QString(*v8::String::Utf8Value(isolate, parentValueString)); |
| 292 | 292 | } |
| 293 | − qDebug() << "Failed to get property, parent of value: " << name << ", parent type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))) << " parent value: " << parentValueQString; | |
| 293 | + qCDebug(scriptengine_v8) << "Failed to get property, parent of value: " << name << ", parent type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))) << " parent value: " << parentValueQString; | |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | if (name == QString("x")) { |
| 297 | 297 | printf("x"); |
| 298 | 298 | } |
| 299 | 299 | //This displays too many messages during correct operation, but is useful for debugging |
| 300 | − //qDebug() << "Failed to get property, parent of value: " << name << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 301 | − //qDebug() << "Backtrace: " << _engine->currentContext()->backtrace(); | |
| 300 | + //qCDebug(scriptengine_v8) << "Failed to get property, parent of value: " << name << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 301 | + //qCDebug(scriptengine_v8) << "Backtrace: " << _engine->currentContext()->backtrace(); | |
| 302 | 302 | return _engine->undefinedValue(); |
| 303 | 303 | /*v8::Local<v8::Value> nullValue = v8::Null(_engine->getIsolate()); |
| 304 | 304 | V8ScriptValue nullScriptValue(_engine->getIsolate(), std::move(nullValue)); |
| @@ -314,7 +314,7 @@ ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue · 9 unmodified lines | ||
| 314 | 314 | v8::HandleScope handleScope(isolate); |
| 315 | 315 | v8::Context::Scope contextScope(_engine->getContext()); |
| 316 | 316 | if (_value.constGet()->IsNullOrUndefined()) { |
| 317 | − qDebug() << "Failed to get property, parent of value: " << arrayIndex << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 317 | + qCDebug(scriptengine_v8) << "Failed to get property, parent of value: " << arrayIndex << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 318 | 318 | return _engine->undefinedValue(); |
| 319 | 319 | } |
| 320 | 320 | if (_value.constGet()->IsObject()) { |
| @@ -326,7 +326,7 @@ ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue · 5 unmodified lines | ||
| 326 | 326 | return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result))); |
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | − qDebug() << "Failed to get property, parent of value: " << arrayIndex << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 329 | + qCDebug(scriptengine_v8) << "Failed to get property, parent of value: " << arrayIndex << " is not a V8 object, reported type: " << QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 330 | 330 | return _engine->undefinedValue(); |
| 331 | 331 | } |
| 332 | 332 | |
| @@ -340,17 +340,17 @@ void ScriptValueV8Wrapper::setData(const ScriptValue& value) { · 7 unmodified lines | ||
| 340 | 340 | // V8TODO Check if it uses same isolate. Would pointer check be enough? |
| 341 | 341 | // Private properties are an experimental feature for now on V8, so we are using regular value for now |
| 342 | 342 | if (_value.constGet()->IsNullOrUndefined()) { |
| 343 | − qDebug() << "ScriptValueV8Wrapper::setData() was called on a value that is null or undefined"; | |
| 343 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::setData() was called on a value that is null or undefined"; | |
| 344 | 344 | return; |
| 345 | 345 | } |
| 346 | 346 | if (_value.constGet()->IsObject()) { |
| 347 | 347 | auto v8Object = v8::Local<v8::Object>::Cast(_value.constGet()); |
| 348 | 348 | if( !v8Object->Set(_engine->getContext(), v8::String::NewFromUtf8(isolate, "__data").ToLocalChecked(), unwrapped.constGet()).FromMaybe(false)) { |
| 349 | − qDebug() << "ScriptValueV8Wrapper::data(): Data object couldn't be created"; | |
| 349 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::data(): Data object couldn't be created"; | |
| 350 | 350 | Q_ASSERT(false); |
| 351 | 351 | } |
| 352 | 352 | } else { |
| 353 | − qDebug() << "ScriptValueV8Wrapper::data() was called on a value that is not an object"; | |
| 353 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::data() was called on a value that is not an object"; | |
| 354 | 354 | Q_ASSERT(false); |
| 355 | 355 | } |
| 356 | 356 | } |
| @@ -364,7 +364,7 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 7 unmodified lines | ||
| 364 | 364 | v8::Context::Scope contextScope(_engine->getContext()); |
| 365 | 365 | V8ScriptValue unwrapped = fullUnwrap(value); |
| 366 | 366 | if (_value.constGet()->IsNullOrUndefined()) { |
| 367 | − qDebug() << "ScriptValueV8Wrapper::setProperty() was called on a value that is null or undefined"; | |
| 367 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::setProperty() was called on a value that is null or undefined"; | |
| 368 | 368 | return; |
| 369 | 369 | } |
| 370 | 370 | if(_value.constGet()->IsObject()) { |
| @@ -376,7 +376,7 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 5 unmodified lines | ||
| 376 | 376 | //v8::Maybe<bool> retVal = object->Set(_engine->getContext(), key, unwrapped.constGet()); |
| 377 | 377 | v8::Maybe<bool> retVal = object->Set(isolate->GetCurrentContext(), key, unwrapped.constGet()); |
| 378 | 378 | if (retVal.IsJust() ? !retVal.FromJust() : true){ |
| 379 | − qDebug(scriptengine) << "Failed to set property"; | |
| 379 | + qCDebug(scriptengine_v8) << "Failed to set property"; | |
| 380 | 380 | } |
| 381 | 381 | } else { |
| 382 | 382 | v8::Local<v8::String> details; |
| @@ -385,8 +385,8 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 2 unmodified lines | ||
| 385 | 385 | v8::String::Utf8Value utf8Value(isolate,details); |
| 386 | 386 | detailsString = *utf8Value; |
| 387 | 387 | } |
| 388 | − qDebug(scriptengine) << "Failed to set property:" + name + " - parent is not an object. Parent details: " + " Type: " + QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 389 | − qDebug(scriptengine) << _engine->currentContext()->backtrace(); | |
| 388 | + qCDebug(scriptengine_v8) << "Failed to set property:" + name + " - parent is not an object. Parent details: " + " Type: " + QString(*v8::String::Utf8Value(isolate, _value.constGet()->TypeOf(isolate))); | |
| 389 | + qCDebug(scriptengine_v8) << _engine->currentContext()->backtrace(); | |
| 390 | 390 | } |
| 391 | 391 | //V8TODO: what about flags? |
| 392 | 392 | //_value.setProperty(name, unwrapped, (V8ScriptValue::PropertyFlags)(int)flags); |
| @@ -400,7 +400,7 @@ void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& va · 7 unmodified lines | ||
| 400 | 400 | v8::Context::Scope contextScope(_engine->getContext()); |
| 401 | 401 | V8ScriptValue unwrapped = fullUnwrap(value); |
| 402 | 402 | if (_value.constGet()->IsNullOrUndefined()) { |
| 403 | − qDebug() << "ScriptValueV8Wrapper::setProperty() was called on a value that is null or undefined"; | |
| 403 | + qCDebug(scriptengine_v8) << "ScriptValueV8Wrapper::setProperty() was called on a value that is null or undefined"; | |
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | 406 | if(_value.constGet()->IsObject()) { |
| @@ -409,10 +409,10 @@ void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& va · 2 unmodified lines | ||
| 409 | 409 | v8::Maybe<bool> retVal(object->Set(_engine->getContext(), arrayIndex, unwrapped.constGet())); |
| 410 | 410 | //v8::Maybe<bool> retVal(object->Set(_value.getContext(), arrayIndex, unwrapped.constGet())); |
| 411 | 411 | if (retVal.IsJust() ? !retVal.FromJust() : true){ |
| 412 | − qDebug(scriptengine) << "Failed to set property"; | |
| 412 | + qCDebug(scriptengine_v8) << "Failed to set property"; | |
| 413 | 413 | } |
| 414 | 414 | } else { |
| 415 | − qDebug(scriptengine) << "Failed to set property: " + QString(arrayIndex) + " - parent is not an object"; | |
| 415 | + qCDebug(scriptengine_v8) << "Failed to set property: " + QString(arrayIndex) + " - parent is not an object"; | |
| 416 | 416 | } |
| 417 | 417 | //V8TODO: what about flags? |
| 418 | 418 | //_value.setProperty(arrayIndex, unwrapped, (V8ScriptValue::PropertyFlags)(int)flags); |
| @@ -427,7 +427,7 @@ void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { · 8 unmodified lines | ||
| 427 | 427 | ScriptValueV8Wrapper* unwrappedPrototype = unwrap(prototype); |
| 428 | 428 | if (unwrappedPrototype) { |
| 429 | 429 | if(unwrappedPrototype->toV8Value().constGet()->IsNullOrUndefined() && _value.constGet()->IsNullOrUndefined()) { |
| 430 | − qDebug(scriptengine) << "Failed to assign prototype - one of values is null or undefined"; | |
| 430 | + qCDebug(scriptengine_v8) << "Failed to assign prototype - one of values is null or undefined"; | |
| 431 | 431 | } |
| 432 | 432 | if(unwrappedPrototype->toV8Value().constGet()->IsObject() && _value.constGet()->IsObject()) { |
| 433 | 433 | auto object = v8::Local<v8::Object>::Cast(_value.get()); |
| @@ -435,10 +435,10 @@ void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { · 1 unmodified line | ||
| 435 | 435 | v8::Maybe<bool> retVal = object->SetPrototype(_engine->getContext(), unwrappedPrototype->toV8Value().constGet()); |
| 436 | 436 | //v8::Maybe<bool> retVal = object->SetPrototype(_value.getContext(), unwrappedPrototype->toV8Value().constGet()); |
| 437 | 437 | if (retVal.IsJust() ? !retVal.FromJust() : true){ |
| 438 | − qDebug(scriptengine) << "Failed to assign prototype"; | |
| 438 | + qCDebug(scriptengine_v8) << "Failed to assign prototype"; | |
| 439 | 439 | } |
| 440 | 440 | } else { |
| 441 | − qDebug(scriptengine) << "Failed to assign prototype - one of values is not an object"; | |
| 441 | + qCDebug(scriptengine_v8) << "Failed to assign prototype - one of values is not an object"; | |
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | } |