Google Glog Demo Code.
来源:互联网 发布:网络诋毁 编辑:程序博客网 时间:2024/06/05 19:30
#include <glog/logging.h>#include <glog/raw_logging.h>#include<vector>using namespace std;void ProcessSignal(const char* data, int size){ LOG(ERROR) << __func__ << ":Error..." << std::string(data,size);}int main(int argc, char* argv[]){ FLAGS_log_dir = "/home/qsun/glog"; google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); google::InstallFailureWriter(&ProcessSignal); int num_cookies = 5; LOG(INFO) << "Found " << num_cookies << " cookies"; LOG(INFO) << "This is INFO"; LOG(WARNING) << "This is WARNING"; LOG(ERROR) << "This is Error"; num_cookies = 100; LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; for(int i = 0; i < num_cookies; i++) { LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; LOG_IF_EVERY_N(WARNING, (i > 62), 10) << "Got the " << google::COUNTER << "th big cookie"; LOG_FIRST_N(ERROR, 10) << "Got the " << google::COUNTER << "th cookie"; } // g++ -o -D NDEBUG glogTest glogTest.o -I /home/qsun/tools/glog/include/ -L /home/qsun/tools/glog/lib/ -lglog DLOG(INFO) << "Debug mode: Found cookies"; // Check Macros CHECK_LT(num_cookies, 101) << "Write failed!"; CHECK_NE(1, 2) << ": The world must be ending!"; // GLOG_v=2 ./glogTestVerbose VLOG(1) << "I'm printed when you run the program with --v=1 or higher"; VLOG(2) << "I'm printed when you run the program with --v=2 or higher"; VLOG_IF(1, (1025 > 1024)) << "I'm printed when size is more than 1024 and when you run the " "program with --v=1 or more"; VLOG_EVERY_N(1, 10) << "I'm printed every 10th occurrence, and when you run the program " "with --v=1 or more. Present occurence is " << 1; VLOG_IF_EVERY_N(1, (1024 > 1024), 10) << "I'm printed on every 10th occurence of case when size is more " " than 1024, when you run the program with --v=1 or more. " "Present occurence is " << 1; // Test FailureSignalHandler // vector<int> a; // a[3]=4; return 0;}
Useful links about google glog:
1. http://code.google.com/p/google-glog/
2. http://www.cnblogs.com/davidyang2415/p/3861109.html
3. http://www.rainhome.org/%E7%BB%86%E7%9C%8Bglog/
4. http://stackoverflow.com/questions/11477384/are-google-log-entries-wrapped-by-a-mutex
5. http://www.codeproject.com/Articles/288827/g-log-An-efficient-asynchronous-logger-using-Cplus
1 0
- Google Glog Demo Code.
- Google glog
- google glog
- Google/glog
- Google glog
- glog 简单demo
- google-glog功能介绍
- google glog 使用方法
- glog(Google Logging Library)
- google glog简介
- Google glog 使用方法
- Google glog 使用方法
- google-glog安装使用
- google glog源码分析
- google glog分析2
- google-glog功能介绍
- google glog使用
- 【C++】google glog库
- 算法精解十(C语言版)
- 定时器(二)---ios NSTimer使用
- vim多窗口使用技巧
- Data analysis example with ggplot and dplyr (analyzing ‘supercar’ data, part 2)
- HDU—2795—Billboard—【数据结构】【线段树】【单点更新】
- Google Glog Demo Code.
- Spring MVC 教程,快速入门,深入分析
- 关联谷歌域名 与 IP, eclipse Install new software
- MacOSX 在文件夹右键服务中添加“新建markdwon文件”
- 一个app打开另一个app的某个activity的问题
- 有关JAVA运算符
- 关于jsoncpp使用上的问题
- Android studio初识一 从小技巧入手
- IOS字体大小,字号的问题