Index: src/ConsoleJsObject.cpp |
=================================================================== |
--- a/src/ConsoleJsObject.cpp |
+++ b/src/ConsoleJsObject.cpp |
@@ -41,18 +41,21 @@ |
message << converted[i].AsString(); |
} |
std::stringstream source; |
v8::Local<v8::StackFrame> frame = v8::StackTrace::CurrentStackTrace(arguments.GetIsolate(), 1)->GetFrame(0); |
source << AdblockPlus::Utils::FromV8String(frame->GetScriptName()); |
source << ":" << frame->GetLineNumber(); |
- AdblockPlus::LogSystem& callback = jsEngine->GetPlatform().GetLogSystem(); |
- callback(logLevel, message.str(), source.str()); |
+ jsEngine->GetPlatform().WithLogSystem( |
+ [logLevel, &message, &source](AdblockPlus::LogSystem& callback) |
+ { |
+ callback(logLevel, message.str(), source.str()); |
+ }); |
} |
void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
{ |
return DoLog(AdblockPlus::LogSystem::LOG_LEVEL_LOG, arguments); |
} |
void DebugCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
@@ -93,18 +96,21 @@ |
else |
traceback << "/* anonymous */"; |
traceback << "() at "; |
traceback << AdblockPlus::Utils::FromV8String(frame->GetScriptName()); |
traceback << ":" << frame->GetLineNumber(); |
traceback << std::endl; |
} |
- AdblockPlus::LogSystem& callback = jsEngine->GetPlatform().GetLogSystem(); |
- callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), ""); |
+ jsEngine->GetPlatform().WithLogSystem( |
+ [&traceback](AdblockPlus::LogSystem& callback) |
+ { |
+ callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), ""); |
+ }); |
} |
} |
AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup( |
AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) |
{ |
obj.SetProperty("log", jsEngine.NewCallback(::LogCallback)); |
obj.SetProperty("debug", jsEngine.NewCallback(::DebugCallback)); |