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

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

Issue 10575037: Include RE2 library (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Less intrusive fix for Android Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/re2/util/hash.cc ('k') | third_party/re2/util/mutex.h » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..53f7198c8ac3e8d81cfb4ca1801ec3031c3e2db9
--- /dev/null
+++ b/third_party/re2/util/logging.h
@@ -0,0 +1,83 @@
+// Copyright 2009 The RE2 Authors. All Rights Reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Simplified version of Google's logging.
+
+#ifndef RE2_UTIL_LOGGING_H__
+#define RE2_UTIL_LOGGING_H__
+
+#ifndef WIN32
+#include <unistd.h> /* for write */
+#endif
+#include <sstream>
+#ifdef WIN32
+#include <io.h>
+#endif
+
+// Debug-only checking.
+#define DCHECK(condition) assert(condition)
+#define DCHECK_EQ(val1, val2) assert((val1) == (val2))
+#define DCHECK_NE(val1, val2) assert((val1) != (val2))
+#define DCHECK_LE(val1, val2) assert((val1) <= (val2))
+#define DCHECK_LT(val1, val2) assert((val1) < (val2))
+#define DCHECK_GE(val1, val2) assert((val1) >= (val2))
+#define DCHECK_GT(val1, val2) assert((val1) > (val2))
+
+// Always-on checking
+#define CHECK(x) if(x){}else LogMessageFatal(__FILE__, __LINE__).stream() << "Check failed: " #x
+#define CHECK_LT(x, y) CHECK((x) < (y))
+#define CHECK_GT(x, y) CHECK((x) > (y))
+#define CHECK_LE(x, y) CHECK((x) <= (y))
+#define CHECK_GE(x, y) CHECK((x) >= (y))
+#define CHECK_EQ(x, y) CHECK((x) == (y))
+#define CHECK_NE(x, y) CHECK((x) != (y))
+
+#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
+
+#define VLOG(x) if((x)>0){}else LOG_INFO.stream()
+
+#ifdef NDEBUG
+#define DEBUG_MODE 0
+#define LOG_DFATAL LOG_ERROR
+#else
+#define DEBUG_MODE 1
+#define LOG_DFATAL LOG_FATAL
+#endif
+
+#define LOG(severity) LOG_ ## severity.stream()
+
+class LogMessage {
+ public:
+ LogMessage(const char* file, int line) {
+ stream() << file << ":" << line << ": ";
+ }
+ ~LogMessage() {
+ stream() << "\n";
+ string s = str_.str();
+ if(write(2, s.data(), s.size()) < 0) {} // shut up gcc
+ }
+ ostream& stream() { return str_; }
+
+ private:
+ std::ostringstream str_;
+ DISALLOW_EVIL_CONSTRUCTORS(LogMessage);
+};
+
+class LogMessageFatal : public LogMessage {
+ public:
+ LogMessageFatal(const char* file, int line)
+ : LogMessage(file, line) { }
+ ~LogMessageFatal() {
+ std::cerr << "\n";
+ abort();
+ }
+ private:
+ DISALLOW_EVIL_CONSTRUCTORS(LogMessageFatal);
+};
+
+#endif // RE2_UTIL_LOGGING_H__
« no previous file with comments | « third_party/re2/util/hash.cc ('k') | third_party/re2/util/mutex.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698