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

Side by Side Diff: third_party/webrtc_overrides/webrtc/base/logging.cc

Issue 1992243002: Revert of Fix backwards WebRTC-in-Chromium override and expose Chromium logging setup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/webrtc_overrides/webrtc/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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // NOTE: 5 // NOTE:
6 // Since this file includes Chromium headers, it must not include 6 // Since this file includes Chromium headers, it must not include
7 // third_party/webrtc/base/logging.h since it defines some of the same macros as 7 // third_party/webrtc/base/logging.h since it defines some of the same macros as
8 // Chromium does and we'll run into conflicts. 8 // Chromium does and we'll run into conflicts.
9 9
10 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) 10 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
11 #include <CoreServices/CoreServices.h> 11 #include <CoreServices/CoreServices.h>
12 #endif // OS_MACOSX 12 #endif // OS_MACOSX
13 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <iomanip> 15 #include <iomanip>
16 #include <string>
17 16
18 #include "base/atomicops.h" 17 #include "base/atomicops.h"
19 #include "base/command_line.h"
20 #include "base/logging.h" 18 #include "base/logging.h"
21 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
22 #include "base/threading/platform_thread.h" 20 #include "base/threading/platform_thread.h"
23 #include "third_party/webrtc/base/stringencode.h" 21 #include "third_party/webrtc/base/stringencode.h"
24 #include "third_party/webrtc/base/stringutils.h" 22 #include "third_party/webrtc/base/stringutils.h"
25 23
26 // This needs to be included after base/logging.h. 24 // This needs to be included after base/logging.h.
27 #include "third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h" 25 #include "third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h"
28 #include "third_party/webrtc_overrides/webrtc/base/logging.h" 26 #include "third_party/webrtc_overrides/webrtc/base/logging.h"
29 27
(...skipping 14 matching lines...) Expand all
44 42
45 void (*g_logging_delegate_function)(const std::string&) = NULL; 43 void (*g_logging_delegate_function)(const std::string&) = NULL;
46 void (*g_extra_logging_init_function)( 44 void (*g_extra_logging_init_function)(
47 void (*logging_delegate_function)(const std::string&)) = NULL; 45 void (*logging_delegate_function)(const std::string&)) = NULL;
48 #ifndef NDEBUG 46 #ifndef NDEBUG
49 static_assert(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId), 47 static_assert(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
50 "Atomic32 not same size as PlatformThreadId"); 48 "Atomic32 not same size as PlatformThreadId");
51 base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0; 49 base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0;
52 #endif 50 #endif
53 51
54 void InitChromiumLoggingAndCommandLine() {
55 // 0 means no arguments, so the null argv is never touched
56 base::CommandLine::Init(0, nullptr);
57
58 // Chromium checks for the presence of --v when deciding log level.
59 // Note that the *value* of --v doesn't matter for this check.
60 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("v", "");
61 logging::InitLogging(logging::LoggingSettings());
62 }
63
64 ///////////////////////////////////////////////////////////////////////////// 52 /////////////////////////////////////////////////////////////////////////////
65 // Constant Labels 53 // Constant Labels
66 ///////////////////////////////////////////////////////////////////////////// 54 /////////////////////////////////////////////////////////////////////////////
67 55
68 const char* FindLabel(int value, const ConstantLabel entries[]) { 56 const char* FindLabel(int value, const ConstantLabel entries[]) {
69 for (int i = 0; entries[i].label; ++i) { 57 for (int i = 0; entries[i].label; ++i) {
70 if (value == entries[i].value) return entries[i].label; 58 if (value == entries[i].value) return entries[i].label;
71 } 59 }
72 return 0; 60 return 0;
73 } 61 }
(...skipping 11 matching lines...) Expand all
85 base::snprintf(buffer, sizeof(buffer), "0x%08x", err); 73 base::snprintf(buffer, sizeof(buffer), "0x%08x", err);
86 return buffer; 74 return buffer;
87 } 75 }
88 76
89 ///////////////////////////////////////////////////////////////////////////// 77 /////////////////////////////////////////////////////////////////////////////
90 // Log helper functions 78 // Log helper functions
91 ///////////////////////////////////////////////////////////////////////////// 79 /////////////////////////////////////////////////////////////////////////////
92 80
93 inline int WebRtcSevToChromeSev(LoggingSeverity sev) { 81 inline int WebRtcSevToChromeSev(LoggingSeverity sev) {
94 switch (sev) { 82 switch (sev) {
95 case LS_NONE:
96 // Used to set the log level for "no logging", so must be less
97 // than LOG_ERROR.
98 return ::logging::LOG_FATAL;
99 case LS_ERROR: 83 case LS_ERROR:
100 return ::logging::LOG_ERROR; 84 return ::logging::LOG_ERROR;
101 case LS_WARNING: 85 case LS_WARNING:
102 return ::logging::LOG_WARNING; 86 return ::logging::LOG_WARNING;
103 case LS_INFO: 87 case LS_INFO:
104 return ::logging::LOG_INFO; 88 return ::logging::LOG_INFO;
105 case LS_VERBOSE: 89 case LS_VERBOSE:
106 case LS_SENSITIVE: 90 case LS_SENSITIVE:
107 return ::logging::LOG_VERBOSE; 91 return ::logging::LOG_VERBOSE;
108 default: 92 default:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 rtc::WebRtcSevToChromeSev(severity_)) << str; 194 rtc::WebRtcSevToChromeSev(severity_)) << str;
211 } 195 }
212 196
213 if (g_logging_delegate_function && severity_ <= LS_INFO) { 197 if (g_logging_delegate_function && severity_ <= LS_INFO) {
214 g_logging_delegate_function(str); 198 g_logging_delegate_function(str);
215 } 199 }
216 } 200 }
217 } 201 }
218 202
219 // static 203 // static
220 void LogMessage::LogToDebug(LoggingSeverity min_sev) { 204 void LogMessage::LogToDebug(int min_sev) {
221 logging::SetMinLogLevel(WebRtcSevToChromeSev(min_sev)); 205 logging::SetMinLogLevel(min_sev);
222 } 206 }
223 207
224 // Note: this function is a copy from the overriden libjingle implementation. 208 // Note: this function is a copy from the overriden libjingle implementation.
225 void LogMultiline(LoggingSeverity level, const char* label, bool input, 209 void LogMultiline(LoggingSeverity level, const char* label, bool input,
226 const void* data, size_t len, bool hex_mode, 210 const void* data, size_t len, bool hex_mode,
227 LogMultilineState* state) { 211 LogMultilineState* state) {
228 // TODO(grunell): This will not do the expected verbosity level checking. We 212 // TODO(grunell): This will not do the expected verbosity level checking. We
229 // need a macro for the multiline logging. 213 // need a macro for the multiline logging.
230 // https://code.google.com/p/webrtc/issues/detail?id=5011 214 // https://code.google.com/p/webrtc/issues/detail?id=5011
231 if (!LOG_CHECK_LEVEL_V(level)) 215 if (!LOG_CHECK_LEVEL_V(level))
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 g_extra_logging_init_function = function; 356 g_extra_logging_init_function = function;
373 } 357 }
374 358
375 bool CheckVlogIsOnHelper( 359 bool CheckVlogIsOnHelper(
376 rtc::LoggingSeverity severity, const char* file, size_t N) { 360 rtc::LoggingSeverity severity, const char* file, size_t N) {
377 return rtc::WebRtcVerbosityLevel(severity) <= 361 return rtc::WebRtcVerbosityLevel(severity) <=
378 ::logging::GetVlogLevelHelper(file, N); 362 ::logging::GetVlogLevelHelper(file, N);
379 } 363 }
380 364
381 } // namespace rtc 365 } // namespace rtc
OLDNEW
« no previous file with comments | « third_party/webrtc_overrides/webrtc/base/logging.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698