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

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

Issue 1982643002: Fix backwards WebRTC-in-Chromium override and expose Chromium logging setup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ...and expose it even if !defined(LOGGING_INSIDE_WEBRTC) 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
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>
16 17
17 #include "base/atomicops.h" 18 #include "base/atomicops.h"
19 #include "base/command_line.h"
18 #include "base/logging.h" 20 #include "base/logging.h"
19 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
20 #include "base/threading/platform_thread.h" 22 #include "base/threading/platform_thread.h"
21 #include "third_party/webrtc/base/stringencode.h" 23 #include "third_party/webrtc/base/stringencode.h"
22 #include "third_party/webrtc/base/stringutils.h" 24 #include "third_party/webrtc/base/stringutils.h"
23 25
24 // This needs to be included after base/logging.h. 26 // This needs to be included after base/logging.h.
25 #include "third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h" 27 #include "third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h"
26 #include "third_party/webrtc_overrides/webrtc/base/logging.h" 28 #include "third_party/webrtc_overrides/webrtc/base/logging.h"
27 29
(...skipping 14 matching lines...) Expand all
42 44
43 void (*g_logging_delegate_function)(const std::string&) = NULL; 45 void (*g_logging_delegate_function)(const std::string&) = NULL;
44 void (*g_extra_logging_init_function)( 46 void (*g_extra_logging_init_function)(
45 void (*logging_delegate_function)(const std::string&)) = NULL; 47 void (*logging_delegate_function)(const std::string&)) = NULL;
46 #ifndef NDEBUG 48 #ifndef NDEBUG
47 static_assert(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId), 49 static_assert(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
48 "Atomic32 not same size as PlatformThreadId"); 50 "Atomic32 not same size as PlatformThreadId");
49 base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0; 51 base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0;
50 #endif 52 #endif
51 53
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
52 ///////////////////////////////////////////////////////////////////////////// 64 /////////////////////////////////////////////////////////////////////////////
53 // Constant Labels 65 // Constant Labels
54 ///////////////////////////////////////////////////////////////////////////// 66 /////////////////////////////////////////////////////////////////////////////
55 67
56 const char* FindLabel(int value, const ConstantLabel entries[]) { 68 const char* FindLabel(int value, const ConstantLabel entries[]) {
57 for (int i = 0; entries[i].label; ++i) { 69 for (int i = 0; entries[i].label; ++i) {
58 if (value == entries[i].value) return entries[i].label; 70 if (value == entries[i].value) return entries[i].label;
59 } 71 }
60 return 0; 72 return 0;
61 } 73 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 rtc::WebRtcSevToChromeSev(severity_)) << str; 206 rtc::WebRtcSevToChromeSev(severity_)) << str;
195 } 207 }
196 208
197 if (g_logging_delegate_function && severity_ <= LS_INFO) { 209 if (g_logging_delegate_function && severity_ <= LS_INFO) {
198 g_logging_delegate_function(str); 210 g_logging_delegate_function(str);
199 } 211 }
200 } 212 }
201 } 213 }
202 214
203 // static 215 // static
204 void LogMessage::LogToDebug(int min_sev) { 216 void LogMessage::LogToDebug(LoggingSeverity min_sev) {
205 logging::SetMinLogLevel(min_sev); 217 logging::SetMinLogLevel(WebRtcSevToChromeSev(min_sev));
Henrik Grunell 2016/05/18 08:43:26 Yes, this was indeed wrong. Great to have it fixed
206 } 218 }
207 219
208 // Note: this function is a copy from the overriden libjingle implementation. 220 // Note: this function is a copy from the overriden libjingle implementation.
209 void LogMultiline(LoggingSeverity level, const char* label, bool input, 221 void LogMultiline(LoggingSeverity level, const char* label, bool input,
210 const void* data, size_t len, bool hex_mode, 222 const void* data, size_t len, bool hex_mode,
211 LogMultilineState* state) { 223 LogMultilineState* state) {
212 // TODO(grunell): This will not do the expected verbosity level checking. We 224 // TODO(grunell): This will not do the expected verbosity level checking. We
213 // need a macro for the multiline logging. 225 // need a macro for the multiline logging.
214 // https://code.google.com/p/webrtc/issues/detail?id=5011 226 // https://code.google.com/p/webrtc/issues/detail?id=5011
215 if (!LOG_CHECK_LEVEL_V(level)) 227 if (!LOG_CHECK_LEVEL_V(level))
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 g_extra_logging_init_function = function; 368 g_extra_logging_init_function = function;
357 } 369 }
358 370
359 bool CheckVlogIsOnHelper( 371 bool CheckVlogIsOnHelper(
360 rtc::LoggingSeverity severity, const char* file, size_t N) { 372 rtc::LoggingSeverity severity, const char* file, size_t N) {
361 return rtc::WebRtcVerbosityLevel(severity) <= 373 return rtc::WebRtcVerbosityLevel(severity) <=
362 ::logging::GetVlogLevelHelper(file, N); 374 ::logging::GetVlogLevelHelper(file, N);
363 } 375 }
364 376
365 } // namespace rtc 377 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698