Add a minimal logging interface and implementation.

Change-Id: Ie65dac4b9e2a77e5118231fde002f78dd33226c5
diff --git a/src/logging.h b/src/logging.h
new file mode 100644
index 0000000..f4d60bf
--- /dev/null
+++ b/src/logging.h
@@ -0,0 +1,101 @@
+// 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 SRC_LOGGING_H_
+#define SRC_LOGGING_H_
+
+#include <cstdlib>
+#include <iostream>  // NOLINT
+#include "src/macros.h"
+
+#define CHECK(x) \
+  if (!(x)) LogMessageFatal(__FILE__, __LINE__).stream() << "Check failed: " #x
+#define CHECK_EQ(x, y) CHECK((x) == (y))
+#define CHECK_NE(x, y) CHECK((x) != (y))
+#define CHECK_LE(x, y) CHECK((x) <= (y))
+#define CHECK_LT(x, y) CHECK((x) < (y))
+#define CHECK_GE(x, y) CHECK((x) >= (y))
+#define CHECK_GT(x, y) CHECK((x) > (y))
+
+#ifndef NDEBUG
+
+#define DCHECK(x) CHECK(x)
+#define DCHECK_EQ(x, y) CHECK_EQ(x, y)
+#define DCHECK_NE(x, y) CHECK_NE(x, y)
+#define DCHECK_LE(x, y) CHECK_LE(x, y)
+#define DCHECK_LT(x, y) CHECK_LT(x, y)
+#define DCHECK_GE(x, y) CHECK_GE(x, y)
+#define DCHECK_GT(x, y) CHECK_GT(x, y)
+
+#else  // NDEBUG
+
+#define DCHECK(condition) \
+  while (false) \
+    CHECK(condition)
+
+#define DCHECK_EQ(val1, val2) \
+  while (false) \
+    CHECK_EQ(val1, val2)
+
+#define DCHECK_NE(val1, val2) \
+  while (false) \
+    CHECK_NE(val1, val2)
+
+#define DCHECK_LE(val1, val2) \
+  while (false) \
+    CHECK_LE(val1, val2)
+
+#define DCHECK_LT(val1, val2) \
+  while (false) \
+    CHECK_LT(val1, val2)
+
+#define DCHECK_GE(val1, val2) \
+  while (false) \
+    CHECK_GE(val1, val2)
+
+#define DCHECK_GT(val1, val2) \
+  while (false) \
+    CHECK_GT(val1, val2)
+
+#define DCHECK_STREQ(str1, str2) \
+  while (false) \
+    CHECK_STREQ(str1, str2)
+
+#endif
+
+#define LOG_INFO LogMessage(__FILE__, __LINE__)
+#define LOG(severity) LOG_ ## severity.stream()
+#define LG LOG(INFO)
+
+class LogMessage {
+ public:
+  LogMessage(const char* file, int line) {}
+  ~LogMessage() { std::cerr << "\n"; }
+  std::ostream& stream() { return std::cerr; }
+ private:
+  DISALLOW_COPY_AND_ASSIGN(LogMessage);
+};
+
+class LogMessageFatal : public LogMessage {
+ public:
+  LogMessageFatal(const char* file, int line)
+    : LogMessage(file, line) {}
+  ~LogMessageFatal() {
+    std::cerr << "\n";
+    std::abort();
+  }
+ private:
+  DISALLOW_COPY_AND_ASSIGN(LogMessageFatal);
+};
+
+#endif  // SRC_LOGGING_H_
diff --git a/src/macros.h b/src/macros.h
new file mode 100644
index 0000000..d75f700
--- /dev/null
+++ b/src/macros.h
@@ -0,0 +1,33 @@
+// 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 SRC_MACROS_H_
+#define SRC_MACROS_H_
+
+// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
+// It goes in the private: declarations in a class.
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+  TypeName(const TypeName&);               \
+  void operator=(const TypeName&)
+
+// A macro to disallow all the implicit constructors, namely the
+// default constructor, copy constructor and operator= functions.
+//
+// This should be used in the private: declarations for a class
+// that wants to prevent anyone from instantiating it. This is
+// especially useful for classes containing only static methods.
+#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
+  TypeName();                                    \
+  DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+#endif  // SRC_MACROS_H_