History

Add V8 logging category

Rename logging category to overte Make all V8 code use logging categories

Dale Glass committed 3 years ago

Commit 0fc2ab81 parent 633319c10 files · +211 −161Browse files

Showing the changes to libraries/script-engine/src/v8/ScriptValueV8Wrapper.cpp (1 of 10 files). Show all

Unified · Split

libraries/script-engine/src/v8/ScriptValueV8Wrapper.cpp+29−29
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 #include "ScriptValueIteratorV8Wrapper.h"
1818
1919 #include "../ScriptEngineLogging.h"
20−
20+#include "ScriptEngineLoggingV8.h"
2121
2222 void ScriptValueV8Wrapper::release() {
2323 // 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
9292 v8::Local<v8::Value> recv;
9393 if (v8This.get()->IsObject()) {
9494 recv = v8This.get();
95− //qDebug() << "V8 This: " << _engine->scriptValueDebugDetailsV8(v8This);
95+ //qCDebug(scriptengine_v8) << "V8 This: " << _engine->scriptValueDebugDetailsV8(v8This);
9696 }else{
9797 recv = _engine->getContext()->Global();
9898 //recv = v8::Null(isolate);
99− //qDebug() << "global";
99+ //qCDebug(scriptengine_v8) << "global";
100100 }
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));
102102 auto maybeResult = v8Function->Call(_engine->getContext(), recv, args.length(), v8Args);
103103 // V8TODO: Exceptions don't seem to actually be caught here?
104104 if (tryCatch.HasCaught()) {
105− qCDebug(scriptengine) << "Function call failed: \"" << _engine->formatErrorMessageFromTryCatch(tryCatch);
105+ qCDebug(scriptengine_v8) << "Function call failed: \"" << _engine->formatErrorMessageFromTryCatch(tryCatch);
106106 }
107107 v8::Local<v8::Value> result;
108108 Q_ASSERT(_engine == _value.getEngine());
@@ -110,7 +110,7 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 1 unmodified line
110110 return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, result)));
111111 } else {
112112 //V8TODO Add more details
113− qWarning("JS function call failed");
113+ qCWarning(scriptengine_v8) << "JS function call failed";
114114 return _engine->undefinedValue();
115115 }
116116 }
@@ -135,7 +135,7 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri · 18 unmodified lines
135135 return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine->getContext(), result)));
136136 } else {
137137 //V8TODO Add more details
138− qWarning("JS function call failed");
138+ qCWarning(scriptengine_v8) << "JS function call failed";
139139 return _engine->undefinedValue();
140140 }*/
141141 }
@@ -163,7 +163,7 @@ ScriptValue ScriptValueV8Wrapper::construct(const ScriptValueList& args) { · 21 unmodified lines
163163 return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, result)));
164164 } else {
165165 //V8TODO Add more details
166− qWarning("JS function call failed");
166+ qCWarning(scriptengine_v8) << "JS function call failed";
167167 return _engine->undefinedValue();
168168 }
169169 }
@@ -205,18 +205,18 @@ ScriptValue ScriptValueV8Wrapper::data() const { · 35 unmodified lines
205205 }
206206 }
207207 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";
209209 // Create data object if it's non-existent or invalid
210210 data = v8::Object::New(isolate);
211211 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";
213213 Q_ASSERT(false);
214214 }
215215 }*/
216216 V8ScriptValue result(_engine, data);
217217 return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result)));
218218 } 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";
220220 Q_ASSERT(false);
221221 }
222222 //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
290290 if (_value.constGet()->ToDetailString(_engine->getContext()).ToLocal(&parentValueString)) {
291291 QString(*v8::String::Utf8Value(isolate, parentValueString));
292292 }
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;
294294 }
295295 }
296296 if (name == QString("x")) {
297297 printf("x");
298298 }
299299 //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();
302302 return _engine->undefinedValue();
303303 /*v8::Local<v8::Value> nullValue = v8::Null(_engine->getIsolate());
304304 V8ScriptValue nullScriptValue(_engine->getIsolate(), std::move(nullValue));
@@ -314,7 +314,7 @@ ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue · 9 unmodified lines
314314 v8::HandleScope handleScope(isolate);
315315 v8::Context::Scope contextScope(_engine->getContext());
316316 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)));
318318 return _engine->undefinedValue();
319319 }
320320 if (_value.constGet()->IsObject()) {
@@ -326,7 +326,7 @@ ScriptValue ScriptValueV8Wrapper::property(quint32 arrayIndex, const ScriptValue · 5 unmodified lines
326326 return ScriptValue(new ScriptValueV8Wrapper(_engine, std::move(result)));
327327 }
328328 }
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)));
330330 return _engine->undefinedValue();
331331 }
332332
@@ -340,17 +340,17 @@ void ScriptValueV8Wrapper::setData(const ScriptValue& value) { · 7 unmodified lines
340340 // V8TODO Check if it uses same isolate. Would pointer check be enough?
341341 // Private properties are an experimental feature for now on V8, so we are using regular value for now
342342 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";
344344 return;
345345 }
346346 if (_value.constGet()->IsObject()) {
347347 auto v8Object = v8::Local<v8::Object>::Cast(_value.constGet());
348348 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";
350350 Q_ASSERT(false);
351351 }
352352 } 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";
354354 Q_ASSERT(false);
355355 }
356356 }
@@ -364,7 +364,7 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 7 unmodified lines
364364 v8::Context::Scope contextScope(_engine->getContext());
365365 V8ScriptValue unwrapped = fullUnwrap(value);
366366 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";
368368 return;
369369 }
370370 if(_value.constGet()->IsObject()) {
@@ -376,7 +376,7 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 5 unmodified lines
376376 //v8::Maybe<bool> retVal = object->Set(_engine->getContext(), key, unwrapped.constGet());
377377 v8::Maybe<bool> retVal = object->Set(isolate->GetCurrentContext(), key, unwrapped.constGet());
378378 if (retVal.IsJust() ? !retVal.FromJust() : true){
379− qDebug(scriptengine) << "Failed to set property";
379+ qCDebug(scriptengine_v8) << "Failed to set property";
380380 }
381381 } else {
382382 v8::Local<v8::String> details;
@@ -385,8 +385,8 @@ void ScriptValueV8Wrapper::setProperty(const QString& name, const ScriptValue& v · 2 unmodified lines
385385 v8::String::Utf8Value utf8Value(isolate,details);
386386 detailsString = *utf8Value;
387387 }
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();
390390 }
391391 //V8TODO: what about flags?
392392 //_value.setProperty(name, unwrapped, (V8ScriptValue::PropertyFlags)(int)flags);
@@ -400,7 +400,7 @@ void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& va · 7 unmodified lines
400400 v8::Context::Scope contextScope(_engine->getContext());
401401 V8ScriptValue unwrapped = fullUnwrap(value);
402402 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";
404404 return;
405405 }
406406 if(_value.constGet()->IsObject()) {
@@ -409,10 +409,10 @@ void ScriptValueV8Wrapper::setProperty(quint32 arrayIndex, const ScriptValue& va · 2 unmodified lines
409409 v8::Maybe<bool> retVal(object->Set(_engine->getContext(), arrayIndex, unwrapped.constGet()));
410410 //v8::Maybe<bool> retVal(object->Set(_value.getContext(), arrayIndex, unwrapped.constGet()));
411411 if (retVal.IsJust() ? !retVal.FromJust() : true){
412− qDebug(scriptengine) << "Failed to set property";
412+ qCDebug(scriptengine_v8) << "Failed to set property";
413413 }
414414 } 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";
416416 }
417417 //V8TODO: what about flags?
418418 //_value.setProperty(arrayIndex, unwrapped, (V8ScriptValue::PropertyFlags)(int)flags);
@@ -427,7 +427,7 @@ void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { · 8 unmodified lines
427427 ScriptValueV8Wrapper* unwrappedPrototype = unwrap(prototype);
428428 if (unwrappedPrototype) {
429429 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";
431431 }
432432 if(unwrappedPrototype->toV8Value().constGet()->IsObject() && _value.constGet()->IsObject()) {
433433 auto object = v8::Local<v8::Object>::Cast(_value.get());
@@ -435,10 +435,10 @@ void ScriptValueV8Wrapper::setPrototype(const ScriptValue& prototype) { · 1 unmodified line
435435 v8::Maybe<bool> retVal = object->SetPrototype(_engine->getContext(), unwrappedPrototype->toV8Value().constGet());
436436 //v8::Maybe<bool> retVal = object->SetPrototype(_value.getContext(), unwrappedPrototype->toV8Value().constGet());
437437 if (retVal.IsJust() ? !retVal.FromJust() : true){
438− qDebug(scriptengine) << "Failed to assign prototype";
438+ qCDebug(scriptengine_v8) << "Failed to assign prototype";
439439 }
440440 } 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";
442442 }
443443 }
444444 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t