|
1487 | 1487 | // MARK: - Debug Messages for the runtime |
1488 | 1488 |
|
1489 | 1489 | void ExecuteWriteValueValidationsAndStopExecutionAndLogStackTrace(Local<Context> context, const TypeEncoding* typeEncoding, void* dest, Local<Value> arg) { |
1490 | | - if (!RuntimeConfig.IsDebug) { |
1491 | | - return; |
1492 | | - } |
1493 | 1490 | Isolate* isolate = context->GetIsolate(); |
1494 | 1491 | std::string destName = typeEncoding->details.interfaceDeclarationReference.name.valuePtr(); |
1495 | 1492 | Local<Value> originArg = arg; |
@@ -1524,32 +1521,35 @@ bool IsTypeEncondingHandldedByDebugMessages(const TypeEncoding* typeEncoding) { |
1524 | 1521 | } |
1525 | 1522 |
|
1526 | 1523 | void LogWriteValueTraceMessage(Local<Context> context, const TypeEncoding* typeEncoding, void* dest, Local<Value> arg) { |
1527 | | - if (!RuntimeConfig.IsDebug) { |
1528 | | - return; |
1529 | | - } |
1530 | 1524 | Isolate* isolate = context->GetIsolate(); |
1531 | 1525 | std::string destName = typeEncoding->details.interfaceDeclarationReference.name.valuePtr(); |
1532 | 1526 | std::string originName = tns::ToString(isolate, arg); |
1533 | 1527 | if (originName == "") { |
1534 | 1528 | // empty string |
1535 | 1529 | originName = "\"\""; |
1536 | 1530 | } |
| 1531 | + // NOTE: stringWithFormat is slow, perhaps use different c string concatenation? |
1537 | 1532 | NSString* message = [NSString stringWithFormat:@"Interop::WriteValue: from {%s} to {%s}", originName.c_str(), destName.c_str()]; |
1538 | 1533 | Log(@"%@", message); |
1539 | 1534 | } |
1540 | 1535 |
|
1541 | 1536 | void Interop::ExecuteWriteValueDebugValidationsIfInDebug(Local<Context> context, const TypeEncoding* typeEncoding, void* dest, Local<Value> arg) { |
| 1537 | + |
1542 | 1538 | if (!RuntimeConfig.IsDebug) { |
1543 | 1539 | return; |
1544 | 1540 | } |
1545 | | - if (arg.IsEmpty() || arg->IsNullOrUndefined()) { |
1546 | | - return; |
1547 | | - } |
1548 | | - if (IsTypeEncondingHandldedByDebugMessages(typeEncoding)) { |
1549 | | - return; |
| 1541 | + id value = Runtime::GetAppConfigValue("logRuntimeDetail"); |
| 1542 | + bool logRuntimeDetail = value ? [value boolValue] : false; |
| 1543 | + if (logRuntimeDetail) { |
| 1544 | + if (arg.IsEmpty() || arg->IsNullOrUndefined()) { |
| 1545 | + return; |
| 1546 | + } |
| 1547 | + if (IsTypeEncondingHandldedByDebugMessages(typeEncoding)) { |
| 1548 | + return; |
| 1549 | + } |
| 1550 | + LogWriteValueTraceMessage(context, typeEncoding, dest, arg); |
| 1551 | + ExecuteWriteValueValidationsAndStopExecutionAndLogStackTrace(context, typeEncoding, dest, arg); |
1550 | 1552 | } |
1551 | | - LogWriteValueTraceMessage(context, typeEncoding, dest, arg); |
1552 | | - ExecuteWriteValueValidationsAndStopExecutionAndLogStackTrace(context, typeEncoding, dest, arg); |
1553 | 1553 | } |
1554 | 1554 |
|
1555 | 1555 | } |
0 commit comments