Advertisement
Guest User

Untitled

a guest
Sep 9th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <glog/logging.h>
  2. #include <gflags/gflags.h>
  3.  
  4. int increment(int* x) {
  5.     (*x)++;
  6.  
  7.     return 42;
  8. }
  9.  
  10. int main(int argc, char* argv[]) {
  11.     google::ParseCommandLineFlags(&argc, &argv, true);
  12.     google::InitGoogleLogging(argv[0]);
  13.  
  14.     int x = 0;
  15.  
  16.     LOG(INFO) << "Info message";
  17.     LOG(WARNING) << "Warning message, x = " << x;
  18.     LOG_IF(INFO, 42 == increment(&x)) << "Shouldn't be logged: " << increment(&x);
  19.     LOG(WARNING) << "x should be 0, but is: " << x;
  20.  
  21.     return 0;
  22. }
  23.  
  24. bash-4.1$ ./log_example --logtostderr
  25. I0909 15:09:53.077044 16647 log_example.cc:16] Info message
  26. W0909 15:09:53.077115 16647 log_example.cc:18] Warning message, x = 0
  27. I0909 15:09:53.077121 16647 log_example.cc:20] Shouldn't be logged: 42
  28. W0909 15:09:53.077124 16647 log_example.cc:22] x should be 0, but is: 2
  29. bash-4.1$ ./log_example --logtostderr --minloglevel=1
  30. W0909 15:09:55.013198 16650 log_example.cc:18] Warning message, x = 0
  31. 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