diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-05-29 19:50:06 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-05-29 19:50:06 +0000 |
commit | 9413f2ff615ae1b933580576183d316c4cb6376c (patch) | |
tree | e5ef88b0191fa3296a34c793a17a16427a041fdf /src/gmock-internal-utils.cc | |
parent | 16cf473930c01cd7a1a51dff65f22c541fbad5b8 (diff) | |
download | googletest-9413f2ff615ae1b933580576183d316c4cb6376c.tar.gz googletest-9413f2ff615ae1b933580576183d316c4cb6376c.tar.bz2 googletest-9413f2ff615ae1b933580576183d316c4cb6376c.zip |
Avoids unnecessary printing of call into to internal buffers;
Made the universal value printer safer when printing char[];
Removed duplicated code in InvokeWith;
Improved gmock_doctor.py.
Diffstat (limited to 'src/gmock-internal-utils.cc')
-rw-r--r-- | src/gmock-internal-utils.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gmock-internal-utils.cc b/src/gmock-internal-utils.cc index 735abce5..ce17d715 100644 --- a/src/gmock-internal-utils.cc +++ b/src/gmock-internal-utils.cc @@ -101,6 +101,22 @@ FailureReporterInterface* GetFailureReporter() { // Protects global resources (stdout in particular) used by Log(). static Mutex g_log_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX); +// Returns true iff a log with the given severity is visible according +// to the --gmock_verbose flag. +bool LogIsVisible(LogSeverity severity) { + if (GMOCK_FLAG(verbose) == kInfoVerbosity) { + // Always show the log if --gmock_verbose=info. + return true; + } else if (GMOCK_FLAG(verbose) == kErrorVerbosity) { + // Always hide it if --gmock_verbose=error. + return false; + } else { + // If --gmock_verbose is neither "info" nor "error", we treat it + // as "warning" (its default value). + return severity == WARNING; + } +} + // Prints the given message to stdout iff 'severity' >= the level // specified by the --gmock_verbose flag. If stack_frames_to_skip >= // 0, also prints the stack trace excluding the top @@ -110,17 +126,8 @@ static Mutex g_log_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX); // conservative. void Log(LogSeverity severity, const string& message, int stack_frames_to_skip) { - if (GMOCK_FLAG(verbose) == kErrorVerbosity) { - // The user is not interested in logs. + if (!LogIsVisible(severity)) return; - } else if (GMOCK_FLAG(verbose) != kInfoVerbosity) { - // The user is interested in warnings but not informational logs. - // Note that invalid values of GMOCK_FLAG(verbose) are treated as - // "warning", which is the default value of the flag. - if (severity == INFO) { - return; - } - } // Ensures that logs from different threads don't interleave. MutexLock l(&g_log_mutex); |