summaryrefslogtreecommitdiff
path: root/src/third_party/s2/base/logging.h
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2012-10-24 17:40:42 -0400
committerHari Khalsa <hkhalsa@10gen.com>2012-10-29 09:28:18 -0400
commit325b42be26c6dda8965f2d6b9b7b64b381f5bd61 (patch)
treedb4db08805b0b1722e10cba723f5ea2dd9e88ca7 /src/third_party/s2/base/logging.h
parent1bd2fc12ef9de5b705dc1d127d02c397441c77e8 (diff)
downloadmongo-325b42be26c6dda8965f2d6b9b7b64b381f5bd61.tar.gz
SERVER-2874 Import S2 the flags library it depends on, add GeoJSON parsing
SERVER-2874 make the S2 stuff compile on mac/windows
Diffstat (limited to 'src/third_party/s2/base/logging.h')
-rwxr-xr-xsrc/third_party/s2/base/logging.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/third_party/s2/base/logging.h b/src/third_party/s2/base/logging.h
new file mode 100755
index 00000000000..28c513227f1
--- /dev/null
+++ b/src/third_party/s2/base/logging.h
@@ -0,0 +1,99 @@
+// Copyright 2010 Google
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef BASE_LOGGING_H
+#define BASE_LOGGING_H
+
+#include <stdlib.h>
+#include <stdlib.h>
+#include <iostream>
+using std::ostream;
+using std::cout;
+using std::endl;
+
+#include "macros.h"
+
+// 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 CHECK_NOTNULL(x) CHECK((x) != NULL)
+
+#ifndef NDEBUG
+// Debug-only checking.
+#define DCHECK(condition) CHECK(condition)
+#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
+#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
+#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
+#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
+#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
+#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
+#else
+#define DCHECK(condition) CHECK(false)
+#define DCHECK_EQ(val1, val2) CHECK(false)
+#define DCHECK_NE(val1, val2) CHECK(false)
+#define DCHECK_LE(val1, val2) CHECK(false)
+#define DCHECK_LT(val1, val2) CHECK(false)
+#define DCHECK_GE(val1, val2) CHECK(false)
+#define DCHECK_GT(val1, val2) CHECK(false)
+#endif
+
+#include "base/port.h"
+#define INFO std::cout
+#define FATAL std::cerr
+#define DFATAL std::cerr
+
+#define S2LOG(x) x
+#define VLOG(x) if (x>0) {} else S2LOG(INFO)
+
+namespace google_base {
+class DateLogger {
+ public:
+ DateLogger();
+ char* const HumanDate();
+ private:
+ char buffer_[9];
+};
+} // namespace google_base
+
+class LogMessage {
+ public:
+ LogMessage(const char* file, int line) {
+ std::cerr << "[" << pretty_date_.HumanDate() << "] "
+ << file << ":" << line << ": ";
+ }
+ ~LogMessage() { std::cerr << "\n"; }
+ std::ostream& stream() { return std::cerr; }
+
+ private:
+ google_base::DateLogger pretty_date_;
+ DISALLOW_COPY_AND_ASSIGN(LogMessage);
+};
+
+class LogMessageFatal : public LogMessage {
+ public:
+ LogMessageFatal(const char* file, int line)
+ : LogMessage(file, line) { }
+ ~LogMessageFatal() {
+ std::cerr << "\n";
+ ::abort();
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LogMessageFatal);
+};
+
+#endif // BASE_LOGGING_H