void UIBinding::Log(Logger::Level level, std::string& message) { if (level > Logger::LWARN) return; std::string methodName("warn"); if (level < Logger::LWARN) methodName = "error"; std::string origMethodName(methodName); origMethodName.append("_orig"); std::vector<AutoUserWindow>& openWindows = UIBinding::GetInstance()->GetOpenWindows(); for (size_t i = 0; i < openWindows.size(); i++) { KObjectRef domWindow = openWindows[i]->GetDOMWindow(); if (domWindow.isNull()) continue; KObjectRef console = domWindow->GetObject("console", 0); if (console.isNull()) continue; KMethodRef method = console->GetMethod(origMethodName.c_str(), 0); if (method.isNull()) method = console->GetMethod(methodName.c_str(), 0); RunOnMainThread(method, ValueList(Value::NewString(message)), false); } }