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

Side by Side Diff: remoting/client/plugin/pepper_client_logger.cc

Issue 6621018: Convert Chromoting plugin logging to appear in client UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make overridden methods virtual for clang Created 9 years, 7 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/client/plugin/pepper_client_logger.h ('k') | remoting/client/plugin/pepper_view.cc » ('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/client/plugin/pepper_client_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/client/plugin/chromoting_instance.h"
13
14 namespace remoting {
15
16 PepperClientLogger::PepperClientLogger(ChromotingInstance* instance)
17 : instance_(instance),
18 message_loop_(MessageLoop::current()) {
19 }
20
21 PepperClientLogger::~PepperClientLogger() {
22 }
23
24 // Copied from base/logging.cc.
25 const char* const log_severity_names[logging::LOG_NUM_SEVERITIES] = {
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);
31
32 // Based in LOG_IS_ON macro in base/logging.h.
33 if (severity >= ::logging::GetMinLogLevel()) {
34 std::string message;
35 base::StringAppendV(&message, format, ap);
36
37 // Standard logging.
38 logging::LogMessage(__FILE__, __LINE__, severity).stream() << message;
39
40 // Send log message to the Chromoting instance so that it can be sent to the
41 // client UI.
42 LogToClientUI(StringPrintf("LOG(%s) %s",
43 log_severity_names[severity], message.c_str()));
44 }
45
46 va_end(ap);
47 }
48
49 void PepperClientLogger::va_VLog(int verboselevel,
50 const char* format,
51 va_list ap) {
52 if (VLOG_IS_ON(verboselevel)) {
53 std::string message;
54 base::StringAppendV(&message, format, ap);
55
56 // Standard verbose logging.
57 VLOG(verboselevel) << message;
58
59 // Send log message to the Chromoting instance so that it can be sent to the
60 // client UI.
61 LogToClientUI(StringPrintf("VLOG(%d) %s", verboselevel, message.c_str()));
62 }
63 }
64
65 void PepperClientLogger::LogToClientUI(const std::string& message) {
66 if (message_loop_ != MessageLoop::current()) {
67 message_loop_->PostTask(
68 FROM_HERE,
69 NewRunnableMethod(this, &PepperClientLogger::LogToClientUI, message));
70 return;
71 }
72
73 instance_->GetScriptableObject()->LogDebugInfo(message);
74 }
75
76 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_client_logger.h ('k') | remoting/client/plugin/pepper_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698