Add an example using glog from Bazel
authorRodrigo Queiro <rodrigoq@google.com>
Tue, 19 Dec 2017 14:42:59 +0000 (15:42 +0100)
committerRodrigo Queiro <rodrigoq@google.com>
Thu, 4 Jan 2018 10:35:53 +0000 (11:35 +0100)
bazel/example/BUILD [new file with mode: 0644]
bazel/example/main.cc [new file with mode: 0644]

diff --git a/bazel/example/BUILD b/bazel/example/BUILD
new file mode 100644 (file)
index 0000000..6b10e2b
--- /dev/null
@@ -0,0 +1,8 @@
+cc_test(
+    name = "main",
+    size = "small",
+    srcs = ["main.cc"],
+    deps = [
+        "//:glog",
+    ],
+)
diff --git a/bazel/example/main.cc b/bazel/example/main.cc
new file mode 100644 (file)
index 0000000..da5c020
--- /dev/null
@@ -0,0 +1,14 @@
+#include <gflags/gflags.h>
+#include <glog/logging.h>
+
+int main(int argc, char* argv[]) {
+  // Initialize Google's logging library.
+  google::InitGoogleLogging(argv[0]);
+
+  // Optional: parse command line flags
+  gflags::ParseCommandLineFlags(&argc, &argv, true);
+
+  LOG(INFO) << "Hello, world!";
+
+  return 0;
+}