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

Unified Diff: third_party/re2/util/logging.h

Issue 1530113002: Revert of Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/re2/util/flags.h ('k') | third_party/re2/util/logging.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/util/logging.h
diff --git a/third_party/re2/util/logging.h b/third_party/re2/util/logging.h
index feac1993fda4e138b65d62a27c98dac1bf974596..d0a2d875b6e02e4ecfec5ad690e467ced67116f3 100644
--- a/third_party/re2/util/logging.h
+++ b/third_party/re2/util/logging.h
@@ -7,13 +7,13 @@
#ifndef RE2_UTIL_LOGGING_H__
#define RE2_UTIL_LOGGING_H__
-#include <stdio.h> /* for fwrite */
+#ifndef WIN32
+#include <unistd.h> /* for write */
+#endif
#include <sstream>
-
-#include "util/util.h"
-#include "util/flags.h"
-
-DECLARE_int32(minloglevel);
+#ifdef WIN32
+#include <io.h>
+#endif
// Debug-only checking.
#define DCHECK(condition) assert(condition)
@@ -33,16 +33,13 @@
#define CHECK_EQ(x, y) CHECK((x) == (y))
#define CHECK_NE(x, y) CHECK((x) != (y))
-#define LOG_INFO LogMessage(__FILE__, __LINE__, 0)
-#define LOG_WARNING LogMessage(__FILE__, __LINE__, 1)
-#define LOG_ERROR LogMessage(__FILE__, __LINE__, 2)
+#define LOG_INFO LogMessage(__FILE__, __LINE__)
+#define LOG_ERROR LOG_INFO
+#define LOG_WARNING LOG_INFO
#define LOG_FATAL LogMessageFatal(__FILE__, __LINE__)
#define LOG_QFATAL LOG_FATAL
-// It seems that one of the Windows header files defines ERROR as 0.
-#ifdef _WIN32
-#define LOG_0 LOG_INFO
-#endif
+#define VLOG(x) if((x)>0){}else LOG_INFO.stream()
#ifdef NDEBUG
#define DEBUG_MODE 0
@@ -54,21 +51,16 @@
#define LOG(severity) LOG_ ## severity.stream()
-#define VLOG(x) if((x)>0){}else LOG_INFO.stream()
-
class LogMessage {
public:
- LogMessage(const char* file, int line, int severity)
- : severity_(severity), flushed_(false) {
+ LogMessage(const char* file, int line) : flushed_(false) {
stream() << file << ":" << line << ": ";
}
void Flush() {
stream() << "\n";
- if (severity_ >= re2::FLAGS_minloglevel) {
- string s = str_.str();
- size_t n = s.size();
- if (fwrite(s.data(), 1, n, stderr) < n) {} // shut up gcc
- }
+ string s = str_.str();
+ int n = (int)s.size(); // shut up msvc
+ if(write(2, s.data(), n) < 0) {} // shut up gcc
flushed_ = true;
}
~LogMessage() {
@@ -77,33 +69,23 @@
}
}
ostream& stream() { return str_; }
-
+
private:
- const int severity_;
bool flushed_;
std::ostringstream str_;
- DISALLOW_COPY_AND_ASSIGN(LogMessage);
+ DISALLOW_EVIL_CONSTRUCTORS(LogMessage);
};
-
-#ifdef _WIN32
-#pragma warning(push)
-#pragma warning(disable: 4722) // destructor never returns
-#endif
class LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char* file, int line)
- : LogMessage(file, line, 3) {}
+ : LogMessage(file, line) { }
~LogMessageFatal() {
Flush();
abort();
}
private:
- DISALLOW_COPY_AND_ASSIGN(LogMessageFatal);
+ DISALLOW_EVIL_CONSTRUCTORS(LogMessageFatal);
};
-#ifdef _WIN32
-#pragma warning(pop)
-#endif
-
#endif // RE2_UTIL_LOGGING_H__
« no previous file with comments | « third_party/re2/util/flags.h ('k') | third_party/re2/util/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698