Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: remoting/host/plugin/host_plugin_logger.cc

Issue 7262015: Conenct Chromoting plugin debug log to JS UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing host logging files Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/plugin/pepper_client_logger.h" 5 #include "remoting/host/plugin/host_plugin_logger.h"
6 6
7 #include <stdarg.h> // va_list 7 #include <stdarg.h> // va_list
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "remoting/client/plugin/chromoting_instance.h" 12 #include "remoting/host/plugin/host_script_object.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 PepperClientLogger::PepperClientLogger(ChromotingInstance* instance) 16 HostPluginLogger::HostPluginLogger(HostNPScriptObject* scriptable)
17 : instance_(instance), 17 : scriptable_object_(scriptable),
18 message_loop_(MessageLoop::current()) { 18 message_loop_(MessageLoop::current()) {
19 } 19 }
20 20
21 PepperClientLogger::~PepperClientLogger() { 21 HostPluginLogger::~HostPluginLogger() {
22 } 22 }
23 23
24 // Copied from base/logging.cc. 24 void HostPluginLogger::va_Log(logging::LogSeverity severity,
25 const char* const log_severity_names[logging::LOG_NUM_SEVERITIES] = { 25 const char* format, va_list ap) {
26 "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" };
27
28 void PepperClientLogger::va_Log(logging::LogSeverity severity,
29 const char* format, va_list ap) {
30 DCHECK(severity >= 0 && severity <= logging::LOG_NUM_SEVERITIES); 26 DCHECK(severity >= 0 && severity <= logging::LOG_NUM_SEVERITIES);
31 27
32 // Based in LOG_IS_ON macro in base/logging.h. 28 // Based in LOG_IS_ON macro in base/logging.h.
33 if (severity >= ::logging::GetMinLogLevel()) { 29 if (severity >= ::logging::GetMinLogLevel()) {
34 std::string message; 30 std::string message;
35 base::StringAppendV(&message, format, ap); 31 base::StringAppendV(&message, format, ap);
36 32
37 // Standard logging. 33 // Standard logging.
38 logging::LogMessage(__FILE__, __LINE__, severity).stream() << message; 34 logging::LogMessage(__FILE__, __LINE__, severity).stream() << message;
39 35
40 // Send log message to the Chromoting instance so that it can be sent to the 36 // Send log message to the Chromoting instance so that it can be sent to the
41 // client UI. 37 // client UI.
dmac 2011/06/26 14:34:44 fix up comment.
garykac 2011/06/27 21:24:20 Done.
42 LogToClientUI(StringPrintf("LOG(%s) %s", 38 LogToHostUI(StringPrintf("LOG(%s) %s",
43 log_severity_names[severity], message.c_str())); 39 log_severity_names[severity], message.c_str()));
44 } 40 }
45 41
46 va_end(ap); 42 va_end(ap);
47 } 43 }
48 44
49 void PepperClientLogger::va_VLog(int verboselevel, 45 void HostPluginLogger::va_VLog(int verboselevel,
50 const char* format, 46 const char* format,
51 va_list ap) { 47 va_list ap) {
52 if (VLOG_IS_ON(verboselevel)) { 48 if (VLOG_IS_ON(verboselevel)) {
53 std::string message; 49 std::string message;
54 base::StringAppendV(&message, format, ap); 50 base::StringAppendV(&message, format, ap);
55 51
56 // Standard verbose logging. 52 // Standard verbose logging.
57 VLOG(verboselevel) << message; 53 VLOG(verboselevel) << message;
58 54
59 // Send log message to the Chromoting instance so that it can be sent to the 55 // Send log message to the Chromoting instance so that it can be sent to the
60 // client UI. 56 // client UI.
dmac 2011/06/26 14:34:44 fix up comment
garykac 2011/06/27 21:24:20 Done.
61 LogToClientUI(StringPrintf("VLOG(%d) %s", verboselevel, message.c_str())); 57 LogToHostUI(StringPrintf("VLOG(%d) %s", verboselevel, message.c_str()));
62 } 58 }
63 } 59 }
64 60
65 void PepperClientLogger::LogToClientUI(const std::string& message) { 61 void HostPluginLogger::LogToHostUI(const std::string& message) {
66 if (message_loop_ != MessageLoop::current()) { 62 if (message_loop_ != MessageLoop::current()) {
67 message_loop_->PostTask( 63 message_loop_->PostTask(
68 FROM_HERE, 64 FROM_HERE,
69 NewRunnableMethod(this, &PepperClientLogger::LogToClientUI, message)); 65 NewRunnableMethod(this, &HostPluginLogger::LogToHostUI, message));
70 return; 66 return;
71 } 67 }
72 68
73 instance_->GetScriptableObject()->LogDebugInfo(message); 69 scriptable_object_->LogDebugInfo(message);
74 } 70 }
75 71
76 } // namespace remoting 72 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698