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

Side by Side Diff: base/logging.h

Issue 2712823003: Various logging-related cleanups & reformatting. (Closed)
Patch Set: Fix base unit-tests Created 3 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
« no previous file with comments | « no previous file | 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 // 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 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // set in |logging_dest|. 199 // set in |logging_dest|.
200 const PathChar* log_file; 200 const PathChar* log_file;
201 LogLockingState lock_log; 201 LogLockingState lock_log;
202 OldFileDeletionState delete_old; 202 OldFileDeletionState delete_old;
203 }; 203 };
204 204
205 // Define different names for the BaseInitLoggingImpl() function depending on 205 // Define different names for the BaseInitLoggingImpl() function depending on
206 // whether NDEBUG is defined or not so that we'll fail to link if someone tries 206 // whether NDEBUG is defined or not so that we'll fail to link if someone tries
207 // to compile logging.cc with NDEBUG but includes logging.h without defining it, 207 // to compile logging.cc with NDEBUG but includes logging.h without defining it,
208 // or vice versa. 208 // or vice versa.
209 #if NDEBUG 209 #if defined(NDEBUG)
210 #define BaseInitLoggingImpl BaseInitLoggingImpl_built_with_NDEBUG 210 #define BaseInitLoggingImpl BaseInitLoggingImpl_built_with_NDEBUG
211 #else 211 #else
212 #define BaseInitLoggingImpl BaseInitLoggingImpl_built_without_NDEBUG 212 #define BaseInitLoggingImpl BaseInitLoggingImpl_built_without_NDEBUG
213 #endif 213 #endif
214 214
215 // Implementation of the InitLogging() method declared below. We use a 215 // Implementation of the InitLogging() method declared below. We use a
216 // more-specific name so we can #define it above without affecting other code 216 // more-specific name so we can #define it above without affecting other code
217 // that has named stuff "InitLogging". 217 // that has named stuff "InitLogging".
218 BASE_EXPORT bool BaseInitLoggingImpl(const LoggingSettings& settings); 218 BASE_EXPORT bool BaseInitLoggingImpl(const LoggingSettings& settings);
219 219
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity 330 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity
331 // Note: the log severities are used to index into the array of names, 331 // Note: the log severities are used to index into the array of names,
332 // see log_severity_names. 332 // see log_severity_names.
333 const LogSeverity LOG_INFO = 0; 333 const LogSeverity LOG_INFO = 0;
334 const LogSeverity LOG_WARNING = 1; 334 const LogSeverity LOG_WARNING = 1;
335 const LogSeverity LOG_ERROR = 2; 335 const LogSeverity LOG_ERROR = 2;
336 const LogSeverity LOG_FATAL = 3; 336 const LogSeverity LOG_FATAL = 3;
337 const LogSeverity LOG_NUM_SEVERITIES = 4; 337 const LogSeverity LOG_NUM_SEVERITIES = 4;
338 338
339 // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode 339 // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode
340 #ifdef NDEBUG 340 #if defined(NDEBUG)
341 const LogSeverity LOG_DFATAL = LOG_ERROR; 341 const LogSeverity LOG_DFATAL = LOG_ERROR;
342 #else 342 #else
343 const LogSeverity LOG_DFATAL = LOG_FATAL; 343 const LogSeverity LOG_DFATAL = LOG_FATAL;
344 #endif 344 #endif
345 345
346 // A few definitions of macros that don't generate much code. These are used 346 // A few definitions of macros that don't generate much code. These are used
347 // by LOG() and LOG_IF, etc. Since these are used all over our code, it's 347 // by LOG() and LOG_IF, etc. Since these are used all over our code, it's
348 // better to have compact code for these operations. 348 // better to have compact code for these operations.
349 #define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ 349 #define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
350 ::logging::ClassName(__FILE__, __LINE__, ::logging::LOG_INFO, ##__VA_ARGS__) 350 ::logging::ClassName(__FILE__, __LINE__, ::logging::LOG_INFO, ##__VA_ARGS__)
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 797
798 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 798 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
799 799
800 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 800 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
801 801
802 // Definitions for DCHECK et al. 802 // Definitions for DCHECK et al.
803 803
804 #if DCHECK_IS_ON() 804 #if DCHECK_IS_ON()
805 805
806 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 806 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
807 COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) 807 COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__)
808 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL 808 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
809 const LogSeverity LOG_DCHECK = LOG_FATAL; 809 const LogSeverity LOG_DCHECK = LOG_FATAL;
810 810
811 #else // DCHECK_IS_ON() 811 #else // DCHECK_IS_ON()
812 812
813 // These are just dummy values. 813 // These are just dummy values.
814 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 814 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
815 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) 815 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__)
816 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO 816 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
817 const LogSeverity LOG_DCHECK = LOG_INFO; 817 const LogSeverity LOG_DCHECK = LOG_INFO;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 #elif NOTIMPLEMENTED_POLICY == 5 1161 #elif NOTIMPLEMENTED_POLICY == 5
1162 #define NOTIMPLEMENTED() do {\ 1162 #define NOTIMPLEMENTED() do {\
1163 static bool logged_once = false;\ 1163 static bool logged_once = false;\
1164 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1164 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1165 logged_once = true;\ 1165 logged_once = true;\
1166 } while(0);\ 1166 } while(0);\
1167 EAT_STREAM_PARAMETERS 1167 EAT_STREAM_PARAMETERS
1168 #endif 1168 #endif
1169 1169
1170 #endif // BASE_LOGGING_H_ 1170 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698