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

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: merge 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
« no previous file with comments | « remoting/host/plugin/host_plugin_logger.h ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/plugin/host_plugin_logger.h"
6
7 #include <stdarg.h> // va_list
8
9 #include "base/logging.h"
10 #include "base/message_loop.h"
11 #include "base/stringprintf.h"
12 #include "remoting/host/plugin/host_script_object.h"
13
14 namespace remoting {
15
16 HostPluginLogger::HostPluginLogger(HostNPScriptObject* scriptable)
17 : scriptable_object_(scriptable),
18 message_loop_(MessageLoop::current()) {
19 }
20
21 HostPluginLogger::~HostPluginLogger() {
22 }
23
24 void HostPluginLogger::va_Log(logging::LogSeverity severity,
25 const char* format, va_list ap) {
26 DCHECK(severity >= 0 && severity <= logging::LOG_NUM_SEVERITIES);
27
28 // Based in LOG_IS_ON macro in base/logging.h.
29 if (severity >= ::logging::GetMinLogLevel()) {
30 std::string message;
31 base::StringAppendV(&message, format, ap);
32
33 // Standard logging.
34 logging::LogMessage(__FILE__, __LINE__, severity).stream() << message;
35
36 // Send log message to the host UI.
37 LogToHostUI(StringPrintf("LOG(%s) %s",
38 log_severity_names[severity], message.c_str()));
39 }
40
41 va_end(ap);
42 }
43
44 void HostPluginLogger::va_VLog(int verboselevel,
45 const char* format,
46 va_list ap) {
47 if (VLOG_IS_ON(verboselevel)) {
48 std::string message;
49 base::StringAppendV(&message, format, ap);
50
51 // Standard verbose logging.
52 VLOG(verboselevel) << message;
53
54 // Send log message to the host UI.
55 LogToHostUI(StringPrintf("VLOG(%d) %s", verboselevel, message.c_str()));
56 }
57 }
58
59 void HostPluginLogger::LogToHostUI(const std::string& message) {
60 if (message_loop_ != MessageLoop::current()) {
61 message_loop_->PostTask(
62 FROM_HERE,
63 NewRunnableMethod(this, &HostPluginLogger::LogToHostUI, message));
64 return;
65 }
66
67 scriptable_object_->LogDebugInfo(message);
68 }
69
70 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_plugin_logger.h ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698