Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <glog/logging.h>
- #include <gflags/gflags.h>
- int increment(int* x) {
- (*x)++;
- return 42;
- }
- int main(int argc, char* argv[]) {
- google::ParseCommandLineFlags(&argc, &argv, true);
- google::InitGoogleLogging(argv[0]);
- int x = 0;
- LOG(INFO) << "Info message";
- LOG(WARNING) << "Warning message, x = " << x;
- LOG_IF(INFO, 42 == increment(&x)) << "Shouldn't be logged: " << increment(&x);
- LOG(WARNING) << "x should be 0, but is: " << x;
- return 0;
- }
- bash-4.1$ ./log_example --logtostderr
- I0909 15:09:53.077044 16647 log_example.cc:16] Info message
- W0909 15:09:53.077115 16647 log_example.cc:18] Warning message, x = 0
- I0909 15:09:53.077121 16647 log_example.cc:20] Shouldn't be logged: 42
- W0909 15:09:53.077124 16647 log_example.cc:22] x should be 0, but is: 2
- bash-4.1$ ./log_example --logtostderr --minloglevel=1
- W0909 15:09:55.013198 16650 log_example.cc:18] Warning message, x = 0
- W0909 15:09:55.013213 16650 log_example.cc:22] x should be 0, but is: 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement