| 399 | } |
| 400 | |
| 401 | void Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 402 | try { |
| 403 | auto isolate = info.GetIsolate(); |
| 404 | std::stringstream ss; |
| 405 | |
| 406 | std::string logString = buildLogString(info); |
| 407 | |
| 408 | if (logString.compare("\n") == 0) { |
| 409 | ss << "Trace"; |
| 410 | } else { |
| 411 | ss << "Trace: " << logString; |
| 412 | } |
| 413 | |
| 414 | ss << std::endl; |
| 415 | |
| 416 | v8::HandleScope scope(isolate); |
| 417 | |
| 418 | auto stack = v8::StackTrace::CurrentStackTrace(isolate, 10, v8::StackTrace::StackTraceOptions::kDetailed); |
| 419 | |
| 420 | auto framesCount = stack->GetFrameCount(); |
| 421 | |
| 422 | for (int i = 0; i < framesCount; i++) { |
| 423 | auto frame = stack->GetFrame(isolate, i); |
| 424 | |
| 425 | ss << buildStacktraceFrameMessage(frame) << std::endl; |
| 426 | } |
| 427 | |
| 428 | std::string log = ss.str(); |
| 429 | __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, log.c_str()); |
| 430 | sendToDevToolsFrontEnd(isolate, ConsoleAPIType::kTrace, info); |
| 431 | } catch (NativeScriptException& e) { |
| 432 | e.ReThrowToV8(); |
| 433 | } catch (std::exception e) { |
| 434 | std::stringstream ss; |
| 435 | ss << "Error: c++ exception: " << e.what() << std::endl; |
| 436 | NativeScriptException nsEx(ss.str()); |
| 437 | nsEx.ReThrowToV8(); |
| 438 | } catch (...) { |
| 439 | NativeScriptException nsEx(std::string("Error: c++ exception!")); |
| 440 | nsEx.ReThrowToV8(); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 445 | try { |
nothing calls this directly
no test coverage detected