diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/base/logging.h | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/base/logging.h')
-rw-r--r-- | chromium/base/logging.h | 206 |
1 files changed, 34 insertions, 172 deletions
diff --git a/chromium/base/logging.h b/chromium/base/logging.h index 71f391f8aff..1a110a565e9 100644 --- a/chromium/base/logging.h +++ b/chromium/base/logging.h @@ -52,10 +52,6 @@ // // LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; // -// The above will cause log messages to be output on the 1st, 11th, 21st, ... -// times it is executed. Note that the special COUNTER value is used to -// identify which repetition is happening. -// // The CHECK(condition) macro is active in both debug and release builds and // effectively performs a LOG(FATAL) which terminates the process and // generates a crashdump unless a debugger is attached. @@ -131,18 +127,13 @@ // GetLastError() on Windows and errno on POSIX). // // The supported severity levels for macros that allow you to specify one -// are (in increasing order of severity) INFO, WARNING, ERROR, ERROR_REPORT, -// and FATAL. +// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. // // Very important: logging a message at the FATAL severity level causes // the program to terminate (after the message is logged). // -// Note the special severity of ERROR_REPORT only available/relevant in normal -// mode, which displays error dialog without terminating the program. There is -// no error dialog for severity ERROR or below in normal mode. -// -// There is also the special severity of DFATAL, which logs FATAL in -// debug mode, ERROR in normal mode. +// There is the special severity of DFATAL, which logs FATAL in debug mode, +// ERROR in normal mode. namespace logging { @@ -175,7 +166,7 @@ enum LoggingDestination { // Indicates that the log file should be locked when being written to. // Unless there is only one single-threaded process that is logging to // the log file, the file should be locked during writes to make each -// log outut atomic. Other writers will block. +// log output atomic. Other writers will block. // // All processes writing to the log file must have their locking set for it to // work properly. Defaults to LOCK_LOG_FILE. @@ -185,11 +176,6 @@ enum LogLockingState { LOCK_LOG_FILE, DONT_LOCK_LOG_FILE }; // Defaults to APPEND_TO_OLD_LOG_FILE. enum OldFileDeletionState { DELETE_OLD_LOG_FILE, APPEND_TO_OLD_LOG_FILE }; -enum DcheckState { - DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS, - ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS -}; - struct BASE_EXPORT LoggingSettings { // The defaults values are: // @@ -197,7 +183,6 @@ struct BASE_EXPORT LoggingSettings { // log_file: NULL // lock_log: LOCK_LOG_FILE // delete_old: APPEND_TO_OLD_LOG_FILE - // dcheck_state: DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS LoggingSettings(); LoggingDestination logging_dest; @@ -207,8 +192,6 @@ struct BASE_EXPORT LoggingSettings { const PathChar* log_file; LogLockingState lock_log; OldFileDeletionState delete_old; - - DcheckState dcheck_state; }; // Define different names for the BaseInitLoggingImpl() function depending on @@ -288,13 +271,6 @@ BASE_EXPORT void SetShowErrorDialogs(bool enable_dialogs); typedef void (*LogAssertHandlerFunction)(const std::string& str); BASE_EXPORT void SetLogAssertHandler(LogAssertHandlerFunction handler); -// Sets the Log Report Handler that will be used to notify of check failures -// in non-debug mode. The default handler shows a dialog box and continues -// the execution, however clients can use this function to override with their -// own handling. -typedef void (*LogReportHandlerFunction)(const std::string& str); -BASE_EXPORT void SetLogReportHandler(LogReportHandlerFunction handler); - // Sets the Log Message Handler that gets passed every log message before // it's sent to other log destinations (if any). // Returns true to signal that it handled the message and the message @@ -311,9 +287,8 @@ const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity const LogSeverity LOG_INFO = 0; const LogSeverity LOG_WARNING = 1; const LogSeverity LOG_ERROR = 2; -const LogSeverity LOG_ERROR_REPORT = 3; -const LogSeverity LOG_FATAL = 4; -const LogSeverity LOG_NUM_SEVERITIES = 5; +const LogSeverity LOG_FATAL = 3; +const LogSeverity LOG_NUM_SEVERITIES = 4; // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode #ifdef NDEBUG @@ -331,9 +306,6 @@ const LogSeverity LOG_DFATAL = LOG_FATAL; logging::ClassName(__FILE__, __LINE__, logging::LOG_WARNING , ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ logging::ClassName(__FILE__, __LINE__, logging::LOG_ERROR , ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_EX_ERROR_REPORT(ClassName, ...) \ - logging::ClassName(__FILE__, __LINE__, \ - logging::LOG_ERROR_REPORT , ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ logging::ClassName(__FILE__, __LINE__, logging::LOG_FATAL , ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ @@ -345,8 +317,6 @@ const LogSeverity LOG_DFATAL = LOG_FATAL; COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) #define COMPACT_GOOGLE_LOG_ERROR \ COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage) -#define COMPACT_GOOGLE_LOG_ERROR_REPORT \ - COMPACT_GOOGLE_LOG_EX_ERROR_REPORT(LogMessage) #define COMPACT_GOOGLE_LOG_FATAL \ COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage) #define COMPACT_GOOGLE_LOG_DFATAL \ @@ -366,10 +336,9 @@ const LogSeverity LOG_DFATAL = LOG_FATAL; const LogSeverity LOG_0 = LOG_ERROR; #endif -// As special cases, we can assume that LOG_IS_ON(ERROR_REPORT) and -// LOG_IS_ON(FATAL) always hold. Also, LOG_IS_ON(DFATAL) always holds -// in debug mode. In particular, CHECK()s will always fire if they -// fail. +// As special cases, we can assume that LOG_IS_ON(FATAL) always holds. Also, +// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will +// always fire if they fail. #define LOG_IS_ON(severity) \ ((::logging::LOG_ ## severity) >= ::logging::GetMinLogLevel()) @@ -438,29 +407,13 @@ const LogSeverity LOG_0 = LOG_ERROR; SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " #if defined(OS_WIN) -#define LOG_GETLASTERROR_STREAM(severity) \ +#define PLOG_STREAM(severity) \ COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \ ::logging::GetLastSystemErrorCode()).stream() -#define LOG_GETLASTERROR(severity) \ - LAZY_STREAM(LOG_GETLASTERROR_STREAM(severity), LOG_IS_ON(severity)) -#define LOG_GETLASTERROR_MODULE_STREAM(severity, module) \ - COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \ - ::logging::GetLastSystemErrorCode(), module).stream() -#define LOG_GETLASTERROR_MODULE(severity, module) \ - LAZY_STREAM(LOG_GETLASTERROR_STREAM(severity, module), \ - LOG_IS_ON(severity)) -// PLOG_STREAM is used by PLOG, which is the usual error logging macro -// for each platform. -#define PLOG_STREAM(severity) LOG_GETLASTERROR_STREAM(severity) #elif defined(OS_POSIX) -#define LOG_ERRNO_STREAM(severity) \ +#define PLOG_STREAM(severity) \ COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ ::logging::GetLastSystemErrorCode()).stream() -#define LOG_ERRNO(severity) \ - LAZY_STREAM(LOG_ERRNO_STREAM(severity), LOG_IS_ON(severity)) -// PLOG_STREAM is used by PLOG, which is the usual error logging macro -// for each platform. -#define PLOG_STREAM(severity) LOG_ERRNO_STREAM(severity) #endif #define PLOG(severity) \ @@ -469,20 +422,6 @@ const LogSeverity LOG_0 = LOG_ERROR; #define PLOG_IF(severity, condition) \ LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) -#if !defined(NDEBUG) -// Debug builds always include DCHECK and DLOG. -#undef LOGGING_IS_OFFICIAL_BUILD -#define LOGGING_IS_OFFICIAL_BUILD 0 -#elif defined(OFFICIAL_BUILD) -// Official release builds always disable and remove DCHECK and DLOG. -#undef LOGGING_IS_OFFICIAL_BUILD -#define LOGGING_IS_OFFICIAL_BUILD 1 -#elif !defined(LOGGING_IS_OFFICIAL_BUILD) -// Unless otherwise specified, unofficial release builds include -// DCHECK and DLOG. -#define LOGGING_IS_OFFICIAL_BUILD 0 -#endif - // The actual stream used isn't important. #define EAT_STREAM_PARAMETERS \ true ? (void) 0 : ::logging::LogMessageVoidify() & LOG_STREAM(FATAL) @@ -494,10 +433,10 @@ const LogSeverity LOG_0 = LOG_ERROR; // We make sure CHECK et al. always evaluates their arguments, as // doing CHECK(FunctionWithSideEffect()) is a common idiom. -#if LOGGING_IS_OFFICIAL_BUILD +#if defined(OFFICIAL_BUILD) && defined(NDEBUG) && !defined(OS_ANDROID) // Make all CHECK functions discard their log strings to reduce code -// bloat for official builds. +// bloat for official release builds. // TODO(akalin): This would be more valuable if there were some way to // remove BreakDebugger() from the backtrace, perhaps by turning it @@ -594,22 +533,16 @@ DEFINE_CHECK_OP_IMPL(GT, > ) #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) #define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) -#if LOGGING_IS_OFFICIAL_BUILD -// In order to have optimized code for official builds, remove DLOGs and -// DCHECKs. -#define ENABLE_DLOG 0 -#define ENABLE_DCHECK 0 - -#elif defined(NDEBUG) -// Otherwise, if we're a release build, remove DLOGs but not DCHECKs -// (since those can still be turned on via a command-line flag). +#if defined(NDEBUG) #define ENABLE_DLOG 0 -#define ENABLE_DCHECK 1 - #else -// Otherwise, we're a debug build so enable DLOGs and DCHECKs. #define ENABLE_DLOG 1 -#define ENABLE_DCHECK 1 +#endif + +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON 0 +#else +#define DCHECK_IS_ON 1 #endif // Definitions for DLOG et al. @@ -654,17 +587,6 @@ enum { DEBUG_MODE = ENABLE_DLOG }; #define DLOG(severity) \ LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) -#if defined(OS_WIN) -#define DLOG_GETLASTERROR(severity) \ - LAZY_STREAM(LOG_GETLASTERROR_STREAM(severity), DLOG_IS_ON(severity)) -#define DLOG_GETLASTERROR_MODULE(severity, module) \ - LAZY_STREAM(LOG_GETLASTERROR_STREAM(severity, module), \ - DLOG_IS_ON(severity)) -#elif defined(OS_POSIX) -#define DLOG_ERRNO(severity) \ - LAZY_STREAM(LOG_ERRNO_STREAM(severity), DLOG_IS_ON(severity)) -#endif - #define DPLOG(severity) \ LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) @@ -674,75 +596,40 @@ enum { DEBUG_MODE = ENABLE_DLOG }; // Definitions for DCHECK et al. -#if ENABLE_DCHECK - -#if defined(NDEBUG) - -BASE_EXPORT DcheckState get_dcheck_state(); -BASE_EXPORT void set_dcheck_state(DcheckState state); +#if DCHECK_IS_ON -#if defined(DCHECK_ALWAYS_ON) - -#define DCHECK_IS_ON() true -#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ - COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL -const LogSeverity LOG_DCHECK = LOG_FATAL; - -#else - -#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ - COMPACT_GOOGLE_LOG_EX_ERROR_REPORT(ClassName , ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_ERROR_REPORT -const LogSeverity LOG_DCHECK = LOG_ERROR_REPORT; -#define DCHECK_IS_ON() \ - ((::logging::get_dcheck_state() == \ - ::logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS) && \ - LOG_IS_ON(DCHECK)) - -#endif // defined(DCHECK_ALWAYS_ON) - -#else // defined(NDEBUG) - -// On a regular debug build, we want to have DCHECKs enabled. #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL const LogSeverity LOG_DCHECK = LOG_FATAL; -#define DCHECK_IS_ON() true - -#endif // defined(NDEBUG) -#else // ENABLE_DCHECK +#else // DCHECK_IS_ON -// These are just dummy values since DCHECK_IS_ON() is always false in -// this case. +// These are just dummy values. #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO const LogSeverity LOG_DCHECK = LOG_INFO; -#define DCHECK_IS_ON() false -#endif // ENABLE_DCHECK -#undef ENABLE_DCHECK +#endif // DCHECK_IS_ON // DCHECK et al. make sure to reference |condition| regardless of // whether DCHECKs are enabled; this is so that we don't get unused // variable warnings if the only use of a variable is in a DCHECK. // This behavior is different from DLOG_IF et al. -#define DCHECK(condition) \ - LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ +#define DCHECK(condition) \ + LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON && !(condition)) \ << "Check failed: " #condition ". " -#define DPCHECK(condition) \ - LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ +#define DPCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON && !(condition)) \ << "Check failed: " #condition ". " // Helper macro for binary operators. // Don't use this macro directly in your code, use DCHECK_EQ et al below. #define DCHECK_OP(name, op, val1, val2) \ - if (DCHECK_IS_ON()) \ + if (DCHECK_IS_ON) \ if (std::string* _result = \ logging::Check##name##Impl((val1), (val2), \ #val1 " " #op " " #val2)) \ @@ -797,32 +684,14 @@ const LogSeverity LOG_DCHECK = LOG_INFO; // above. class BASE_EXPORT LogMessage { public: - LogMessage(const char* file, int line, LogSeverity severity, int ctr); - - // Two special constructors that generate reduced amounts of code at - // LOG call sites for common cases. - // - // Used for LOG(INFO): Implied are: - // severity = LOG_INFO, ctr = 0 - // - // Using this constructor instead of the more complex constructor above - // saves a couple of bytes per call site. - LogMessage(const char* file, int line); - - // Used for LOG(severity) where severity != INFO. Implied - // are: ctr = 0 - // - // Using this constructor instead of the more complex constructor above - // saves a couple of bytes per call site. + // Used for LOG(severity). LogMessage(const char* file, int line, LogSeverity severity); - // A special constructor used for check failures. Takes ownership - // of the given string. - // Implied severity = LOG_FATAL + // Used for CHECK_EQ(), etc. Takes ownership of the given string. + // Implied severity = LOG_FATAL. LogMessage(const char* file, int line, std::string* result); - // A special constructor used for check failures, with the option to - // specify severity. Takes ownership of the given string. + // Used for DCHECK_EQ(), etc. Takes ownership of the given string. LogMessage(const char* file, int line, LogSeverity severity, std::string* result); @@ -890,6 +759,7 @@ typedef int SystemErrorCode; // Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to // pull in windows.h just for GetLastError() and DWORD. BASE_EXPORT SystemErrorCode GetLastSystemErrorCode(); +BASE_EXPORT std::string SystemErrorCodeToString(SystemErrorCode error_code); #if defined(OS_WIN) // Appends a formatted system message of the GetLastError() type. @@ -898,12 +768,6 @@ class BASE_EXPORT Win32ErrorLogMessage { Win32ErrorLogMessage(const char* file, int line, LogSeverity severity, - SystemErrorCode err, - const char* module); - - Win32ErrorLogMessage(const char* file, - int line, - LogSeverity severity, SystemErrorCode err); // Appends the error message before destructing the encapsulated class. @@ -913,8 +777,6 @@ class BASE_EXPORT Win32ErrorLogMessage { private: SystemErrorCode err_; - // Optional name of the module defining the error. - const char* module_; LogMessage log_message_; DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); |