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

Side by Side Diff: third_party/libjingle/overrides/talk/base/logging.cc

Issue 15741003: Moving WebRTC logging related files from content to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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 | « third_party/libjingle/overrides/talk/base/logging.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "third_party/libjingle/overrides/talk/base/logging.h" 5 #include "third_party/libjingle/overrides/talk/base/logging.h"
6 6
7 #if defined(OS_MACOSX) && !defined(OS_IOS) 7 #if defined(OS_MACOSX) && !defined(OS_IOS)
8 #include <CoreServices/CoreServices.h> 8 #include <CoreServices/CoreServices.h>
9 #endif // OS_MACOSX 9 #endif // OS_MACOSX
10 10
11 #include <iomanip> 11 #include <iomanip>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
16 #include "third_party/libjingle/overrides/logging/log_message_delegate.h"
17 #include "third_party/libjingle/source/talk/base/stream.h" 16 #include "third_party/libjingle/source/talk/base/stream.h"
18 #include "third_party/libjingle/source/talk/base/stringencode.h" 17 #include "third_party/libjingle/source/talk/base/stringencode.h"
19 #include "third_party/libjingle/source/talk/base/stringutils.h" 18 #include "third_party/libjingle/source/talk/base/stringutils.h"
20 19
21 // From this file we can't use VLOG since it expands into usage of the __FILE__ 20 // From this file we can't use VLOG since it expands into usage of the __FILE__
22 // macro (for correct filtering). The actual logging call from LOG_E is in 21 // macro (for correct filtering). The actual logging call from LOG_E is in
23 // ~LogEHelper, and from DIAGNOSTIC_LOG in ~DiagnosticLogMessage. Note that the 22 // ~LogEHelper, and from DIAGNOSTIC_LOG in ~DiagnosticLogMessage. Note that the
24 // second parameter to the LAZY_STREAM macro is true since the filter check has 23 // second parameter to the LAZY_STREAM macro is true since the filter check has
25 // already been done for LOG_E and DIAGNOSTIC_LOG. 24 // already been done for LOG_E and DIAGNOSTIC_LOG.
26 #define LOG_LAZY_STREAM_DIRECT(file_name, line_number, sev) \ 25 #define LOG_LAZY_STREAM_DIRECT(file_name, line_number, sev) \
27 LAZY_STREAM(logging::LogMessage(file_name, line_number, \ 26 LAZY_STREAM(logging::LogMessage(file_name, line_number, \
28 -sev).stream(), true) 27 -sev).stream(), true)
29 #define LOG_E_BASE LOG_LAZY_STREAM_DIRECT 28 #define LOG_E_BASE LOG_LAZY_STREAM_DIRECT
30 29
31 namespace talk_base { 30 namespace talk_base {
32 31
33 LogMessageDelegate* g_logging_delegate = NULL; 32 void (*g_logging_delegate_function)(const std::string&) = NULL;
34 #ifndef NDEBUG 33 #ifndef NDEBUG
35 COMPILE_ASSERT(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId), 34 COMPILE_ASSERT(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
36 atomic32_not_same_size_as_platformthreadid); 35 atomic32_not_same_size_as_platformthreadid);
37 base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0; 36 base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0;
38 #endif 37 #endif
39 38
40 ///////////////////////////////////////////////////////////////////////////// 39 /////////////////////////////////////////////////////////////////////////////
41 // Constant Labels 40 // Constant Labels
42 ///////////////////////////////////////////////////////////////////////////// 41 /////////////////////////////////////////////////////////////////////////////
43 42
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 : file_name_(file), 143 : file_name_(file),
145 line_(line), 144 line_(line),
146 severity_(severity), 145 severity_(severity),
147 log_to_chrome_(log_to_chrome) { 146 log_to_chrome_(log_to_chrome) {
148 } 147 }
149 148
150 DiagnosticLogMessage::~DiagnosticLogMessage() { 149 DiagnosticLogMessage::~DiagnosticLogMessage() {
151 const std::string& str = print_stream_.str(); 150 const std::string& str = print_stream_.str();
152 if (log_to_chrome_) 151 if (log_to_chrome_)
153 LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str; 152 LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str;
154 if (g_logging_delegate && severity_ <= LS_INFO) 153 if (g_logging_delegate_function && severity_ <= LS_INFO)
155 g_logging_delegate->LogMessage(str); 154 g_logging_delegate_function(str);
156 } 155 }
157 156
158 // Note: this function is a copy from the overriden libjingle implementation. 157 // Note: this function is a copy from the overriden libjingle implementation.
159 void LogMultiline(LoggingSeverity level, const char* label, bool input, 158 void LogMultiline(LoggingSeverity level, const char* label, bool input,
160 const void* data, size_t len, bool hex_mode, 159 const void* data, size_t len, bool hex_mode,
161 LogMultilineState* state) { 160 LogMultilineState* state) {
162 if (!LOG_CHECK_LEVEL_V(level)) 161 if (!LOG_CHECK_LEVEL_V(level))
163 return; 162 return;
164 163
165 const char * direction = (input ? " << " : " >> "); 164 const char * direction = (input ? " << " : " >> ");
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } else { 265 } else {
267 LOG_V(level) << label << direction << "## omitted for privacy ##"; 266 LOG_V(level) << label << direction << "## omitted for privacy ##";
268 } 267 }
269 } 268 }
270 269
271 if (state) { 270 if (state) {
272 state->unprintable_count_[input] = consecutive_unprintable; 271 state->unprintable_count_[input] = consecutive_unprintable;
273 } 272 }
274 } 273 }
275 274
276 void InitDiagnosticLoggingDelegate(LogMessageDelegate* delegate) { 275 void InitDiagnosticLoggingDelegateFunction(
276 void (*delegate)(const std::string&)) {
277 #ifndef NDEBUG 277 #ifndef NDEBUG
278 // Ensure that this function is always called from the same thread. 278 // Ensure that this function is always called from the same thread.
279 base::subtle::NoBarrier_CompareAndSwap(&g_init_logging_delegate_thread_id, 0, 279 base::subtle::NoBarrier_CompareAndSwap(&g_init_logging_delegate_thread_id, 0,
280 static_cast<base::subtle::Atomic32>(base::PlatformThread::CurrentId())); 280 static_cast<base::subtle::Atomic32>(base::PlatformThread::CurrentId()));
281 DCHECK_EQ(g_init_logging_delegate_thread_id, 281 DCHECK_EQ(g_init_logging_delegate_thread_id,
282 base::PlatformThread::CurrentId()); 282 base::PlatformThread::CurrentId());
283 #endif 283 #endif
284 CHECK(!g_logging_delegate); 284 CHECK(!g_logging_delegate_function);
285 CHECK(delegate); 285 CHECK(delegate);
286 g_logging_delegate = delegate; 286 g_logging_delegate_function = delegate;
287 } 287 }
288 288
289 } // namespace talk_base 289 } // namespace talk_base
OLDNEW
« no previous file with comments | « third_party/libjingle/overrides/talk/base/logging.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698