Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/ConsoleJsObject.cpp

Issue 29498576: Issue 4832 - remove API allowing changing of LogSystem after Initialization of JsEngine (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 26, 2017, 2:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 27 matching lines...) Expand all
38 if (i > 0) 38 if (i > 0)
39 message << " "; 39 message << " ";
40 message << converted[i].AsString(); 40 message << converted[i].AsString();
41 } 41 }
42 42
43 std::stringstream source; 43 std::stringstream source;
44 v8::Local<v8::StackFrame> frame = v8::StackTrace::CurrentStackTrace(argument s.GetIsolate(), 1)->GetFrame(0); 44 v8::Local<v8::StackFrame> frame = v8::StackTrace::CurrentStackTrace(argument s.GetIsolate(), 1)->GetFrame(0);
45 source << AdblockPlus::Utils::FromV8String(frame->GetScriptName()); 45 source << AdblockPlus::Utils::FromV8String(frame->GetScriptName());
46 source << ":" << frame->GetLineNumber(); 46 source << ":" << frame->GetLineNumber();
47 47
48 AdblockPlus::LogSystemPtr callback = jsEngine->GetLogSystem(); 48 AdblockPlus::LogSystem& callback = jsEngine->GetLogSystem();
49 (*callback)(logLevel, message.str(), source.str()); 49 callback(logLevel, message.str(), source.str());
50 } 50 }
51 51
52 void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) 52 void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
53 { 53 {
54 return DoLog(AdblockPlus::LogSystem::LOG_LEVEL_LOG, arguments); 54 return DoLog(AdblockPlus::LogSystem::LOG_LEVEL_LOG, arguments);
55 } 55 }
56 56
57 void DebugCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) 57 void DebugCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
58 { 58 {
59 DoLog(AdblockPlus::LogSystem::LOG_LEVEL_LOG, arguments); 59 DoLog(AdblockPlus::LogSystem::LOG_LEVEL_LOG, arguments);
(...skipping 30 matching lines...) Expand all
90 if (name.size()) 90 if (name.size())
91 traceback << name; 91 traceback << name;
92 else 92 else
93 traceback << "/* anonymous */"; 93 traceback << "/* anonymous */";
94 traceback << "() at "; 94 traceback << "() at ";
95 traceback << AdblockPlus::Utils::FromV8String(frame->GetScriptName()); 95 traceback << AdblockPlus::Utils::FromV8String(frame->GetScriptName());
96 traceback << ":" << frame->GetLineNumber(); 96 traceback << ":" << frame->GetLineNumber();
97 traceback << std::endl; 97 traceback << std::endl;
98 } 98 }
99 99
100 AdblockPlus::LogSystemPtr callback = jsEngine->GetLogSystem(); 100 AdblockPlus::LogSystem& callback = jsEngine->GetLogSystem();
101 (*callback)(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), ""); 101 callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), "");
102 } 102 }
103 } 103 }
104 104
105 AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup( 105 AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup(
106 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) 106 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj)
107 { 107 {
108 obj.SetProperty("log", jsEngine.NewCallback(::LogCallback)); 108 obj.SetProperty("log", jsEngine.NewCallback(::LogCallback));
109 obj.SetProperty("debug", jsEngine.NewCallback(::DebugCallback)); 109 obj.SetProperty("debug", jsEngine.NewCallback(::DebugCallback));
110 obj.SetProperty("info", jsEngine.NewCallback(::InfoCallback)); 110 obj.SetProperty("info", jsEngine.NewCallback(::InfoCallback));
111 obj.SetProperty("warn", jsEngine.NewCallback(::WarnCallback)); 111 obj.SetProperty("warn", jsEngine.NewCallback(::WarnCallback));
112 obj.SetProperty("error", jsEngine.NewCallback(::ErrorCallback)); 112 obj.SetProperty("error", jsEngine.NewCallback(::ErrorCallback));
113 obj.SetProperty("trace", jsEngine.NewCallback(::TraceCallback)); 113 obj.SetProperty("trace", jsEngine.NewCallback(::TraceCallback));
114 return obj; 114 return obj;
115 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld