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

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: More comments and a new case(LS_NONE) 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() {
tommi (sloooow) - chröme 2016/05/18 11:47:50 this function shouldn't be here - is it unused?
katrielc 2016/05/18 12:00:46 It's currently unused, but the plan is to call it
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 11 matching lines...) Expand all
73 base::snprintf(buffer, sizeof(buffer), "0x%08x", err); 85 base::snprintf(buffer, sizeof(buffer), "0x%08x", err);
74 return buffer; 86 return buffer;
75 } 87 }
76 88
77 ///////////////////////////////////////////////////////////////////////////// 89 /////////////////////////////////////////////////////////////////////////////
78 // Log helper functions 90 // Log helper functions
79 ///////////////////////////////////////////////////////////////////////////// 91 /////////////////////////////////////////////////////////////////////////////
80 92
81 inline int WebRtcSevToChromeSev(LoggingSeverity sev) { 93 inline int WebRtcSevToChromeSev(LoggingSeverity sev) {
82 switch (sev) { 94 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;
83 case LS_ERROR: 99 case LS_ERROR:
84 return ::logging::LOG_ERROR; 100 return ::logging::LOG_ERROR;
85 case LS_WARNING: 101 case LS_WARNING:
86 return ::logging::LOG_WARNING; 102 return ::logging::LOG_WARNING;
87 case LS_INFO: 103 case LS_INFO:
88 return ::logging::LOG_INFO; 104 return ::logging::LOG_INFO;
89 case LS_VERBOSE: 105 case LS_VERBOSE:
90 case LS_SENSITIVE: 106 case LS_SENSITIVE:
91 return ::logging::LOG_VERBOSE; 107 return ::logging::LOG_VERBOSE;
92 default: 108 default:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 rtc::WebRtcSevToChromeSev(severity_)) << str; 210 rtc::WebRtcSevToChromeSev(severity_)) << str;
195 } 211 }
196 212
197 if (g_logging_delegate_function && severity_ <= LS_INFO) { 213 if (g_logging_delegate_function && severity_ <= LS_INFO) {
198 g_logging_delegate_function(str); 214 g_logging_delegate_function(str);
199 } 215 }
200 } 216 }
201 } 217 }
202 218
203 // static 219 // static
204 void LogMessage::LogToDebug(int min_sev) { 220 void LogMessage::LogToDebug(LoggingSeverity min_sev) {
205 logging::SetMinLogLevel(min_sev); 221 logging::SetMinLogLevel(WebRtcSevToChromeSev(min_sev));
206 } 222 }
207 223
208 // Note: this function is a copy from the overriden libjingle implementation. 224 // Note: this function is a copy from the overriden libjingle implementation.
209 void LogMultiline(LoggingSeverity level, const char* label, bool input, 225 void LogMultiline(LoggingSeverity level, const char* label, bool input,
210 const void* data, size_t len, bool hex_mode, 226 const void* data, size_t len, bool hex_mode,
211 LogMultilineState* state) { 227 LogMultilineState* state) {
212 // TODO(grunell): This will not do the expected verbosity level checking. We 228 // TODO(grunell): This will not do the expected verbosity level checking. We
213 // need a macro for the multiline logging. 229 // need a macro for the multiline logging.
214 // https://code.google.com/p/webrtc/issues/detail?id=5011 230 // https://code.google.com/p/webrtc/issues/detail?id=5011
215 if (!LOG_CHECK_LEVEL_V(level)) 231 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; 372 g_extra_logging_init_function = function;
357 } 373 }
358 374
359 bool CheckVlogIsOnHelper( 375 bool CheckVlogIsOnHelper(
360 rtc::LoggingSeverity severity, const char* file, size_t N) { 376 rtc::LoggingSeverity severity, const char* file, size_t N) {
361 return rtc::WebRtcVerbosityLevel(severity) <= 377 return rtc::WebRtcVerbosityLevel(severity) <=
362 ::logging::GetVlogLevelHelper(file, N); 378 ::logging::GetVlogLevelHelper(file, N);
363 } 379 }
364 380
365 } // namespace rtc 381 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698