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

Side by Side Diff: webrtc/base/logging.h

Issue 2718663005: Replace NULL with nullptr or null in webrtc/base/. (Closed)
Patch Set: Fixing Windows and formatting issues. Created 3 years, 9 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 | « webrtc/base/ifaddrs-android.cc ('k') | webrtc/base/logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Virtual sink interface that can receive log messages. 132 // Virtual sink interface that can receive log messages.
133 class LogSink { 133 class LogSink {
134 public: 134 public:
135 LogSink() {} 135 LogSink() {}
136 virtual ~LogSink() {} 136 virtual ~LogSink() {}
137 virtual void OnLogMessage(const std::string& message) = 0; 137 virtual void OnLogMessage(const std::string& message) = 0;
138 }; 138 };
139 139
140 class LogMessage { 140 class LogMessage {
141 public: 141 public:
142 LogMessage(const char* file, int line, LoggingSeverity sev, 142 LogMessage(const char* file,
143 LogErrorContext err_ctx = ERRCTX_NONE, int err = 0, 143 int line,
144 const char* module = NULL); 144 LoggingSeverity sev,
145 LogErrorContext err_ctx = ERRCTX_NONE,
146 int err = 0,
147 const char* module = nullptr);
145 148
146 LogMessage(const char* file, 149 LogMessage(const char* file,
147 int line, 150 int line,
148 LoggingSeverity sev, 151 LoggingSeverity sev,
149 const std::string& tag); 152 const std::string& tag);
150 153
151 ~LogMessage(); 154 ~LogMessage();
152 155
153 static inline bool Loggable(LoggingSeverity sev) { return (sev >= min_sev_); } 156 static inline bool Loggable(LoggingSeverity sev) { return (sev >= min_sev_); }
154 std::ostream& stream() { return print_stream_; } 157 std::ostream& stream() { return print_stream_; }
(...skipping 23 matching lines...) Expand all
178 // Sets whether logs will be directed to stderr in debug mode. 181 // Sets whether logs will be directed to stderr in debug mode.
179 static void SetLogToStderr(bool log_to_stderr); 182 static void SetLogToStderr(bool log_to_stderr);
180 183
181 // Stream: Any non-blocking stream interface. LogMessage takes ownership of 184 // Stream: Any non-blocking stream interface. LogMessage takes ownership of
182 // the stream. Multiple streams may be specified by using AddLogToStream. 185 // the stream. Multiple streams may be specified by using AddLogToStream.
183 // LogToStream is retained for backwards compatibility; when invoked, it 186 // LogToStream is retained for backwards compatibility; when invoked, it
184 // will discard any previously set streams and install the specified stream. 187 // will discard any previously set streams and install the specified stream.
185 // GetLogToStream gets the severity for the specified stream, of if none 188 // GetLogToStream gets the severity for the specified stream, of if none
186 // is specified, the minimum stream severity. 189 // is specified, the minimum stream severity.
187 // RemoveLogToStream removes the specified stream, without destroying it. 190 // RemoveLogToStream removes the specified stream, without destroying it.
188 static int GetLogToStream(LogSink* stream = NULL); 191 static int GetLogToStream(LogSink* stream = nullptr);
189 static void AddLogToStream(LogSink* stream, LoggingSeverity min_sev); 192 static void AddLogToStream(LogSink* stream, LoggingSeverity min_sev);
190 static void RemoveLogToStream(LogSink* stream); 193 static void RemoveLogToStream(LogSink* stream);
191 194
192 // Testing against MinLogSeverity allows code to avoid potentially expensive 195 // Testing against MinLogSeverity allows code to avoid potentially expensive
193 // logging operations by pre-checking the logging level. 196 // logging operations by pre-checking the logging level.
194 static int GetMinLogSeverity() { return min_sev_; } 197 static int GetMinLogSeverity() { return min_sev_; }
195 198
196 // Parses the provided parameter stream to configure the options above. 199 // Parses the provided parameter stream to configure the options above.
197 // Useful for configuring logging from the command line. 200 // Useful for configuring logging from the command line.
198 static void ConfigureLogging(const char* params); 201 static void ConfigureLogging(const char* params);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 250
248 class LogMultilineState { 251 class LogMultilineState {
249 public: 252 public:
250 size_t unprintable_count_[2]; 253 size_t unprintable_count_[2];
251 LogMultilineState() { 254 LogMultilineState() {
252 unprintable_count_[0] = unprintable_count_[1] = 0; 255 unprintable_count_[0] = unprintable_count_[1] = 0;
253 } 256 }
254 }; 257 };
255 258
256 // When possible, pass optional state variable to track various data across 259 // When possible, pass optional state variable to track various data across
257 // multiple calls to LogMultiline. Otherwise, pass NULL. 260 // multiple calls to LogMultiline. Otherwise, pass null.
258 void LogMultiline(LoggingSeverity level, const char* label, bool input, 261 void LogMultiline(LoggingSeverity level, const char* label, bool input,
259 const void* data, size_t len, bool hex_mode, 262 const void* data, size_t len, bool hex_mode,
260 LogMultilineState* state); 263 LogMultilineState* state);
261 264
262 #ifndef LOG 265 #ifndef LOG
263 266
264 // The following non-obvious technique for implementation of a 267 // The following non-obvious technique for implementation of a
265 // conditional log stream was stolen from google3/base/logging.h. 268 // conditional log stream was stolen from google3/base/logging.h.
266 269
267 // This class is used to explicitly ignore values in the conditional 270 // This class is used to explicitly ignore values in the conditional
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 (0) 347 (0)
345 #elif defined(WEBRTC_POSIX) 348 #elif defined(WEBRTC_POSIX)
346 #define LOG_ERR_EX(sev, err) \ 349 #define LOG_ERR_EX(sev, err) \
347 LOG_ERRNO_EX(sev, err) 350 LOG_ERRNO_EX(sev, err)
348 #define LOG_ERR(sev) \ 351 #define LOG_ERR(sev) \
349 LOG_ERRNO(sev) 352 LOG_ERRNO(sev)
350 #define LAST_SYSTEM_ERROR \ 353 #define LAST_SYSTEM_ERROR \
351 (errno) 354 (errno)
352 #endif // WEBRTC_WIN 355 #endif // WEBRTC_WIN
353 356
354 #define LOG_TAG(sev, tag) \ 357 #define LOG_TAG(sev, tag) \
355 LOG_SEVERITY_PRECONDITION(sev) \ 358 LOG_SEVERITY_PRECONDITION(sev) \
356 rtc::LogMessage(NULL, 0, sev, tag).stream() 359 rtc::LogMessage(nullptr, 0, sev, tag).stream()
357 360
358 #define PLOG(sev, err) \ 361 #define PLOG(sev, err) \
359 LOG_ERR_EX(sev, err) 362 LOG_ERR_EX(sev, err)
360 363
361 // TODO(?): Add an "assert" wrapper that logs in the same manner. 364 // TODO(?): Add an "assert" wrapper that logs in the same manner.
362 365
363 #endif // LOG 366 #endif // LOG
364 367
365 } // namespace rtc 368 } // namespace rtc
366 369
367 #endif // WEBRTC_BASE_LOGGING_H_ 370 #endif // WEBRTC_BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « webrtc/base/ifaddrs-android.cc ('k') | webrtc/base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698