glog的使用

主要还是看官方文档吧

win32下,把#define GLOG_NO_ABBREVIATED_SEVERITIES 放到#include <windows.h>之前,具体说明文档中有说。

glog不支持分天滚动打印,是PID滚动打印,不过可以自己改源码定制需求:http://blog.csdn.net/tomisaboy/article/details/51418845

glog的LOG(LEVEL)是线程安全的

glog 不支持Unicode

glog跨DLL打印的时候,也需要初始化glog,然后再打印,不然不能。: http://ask.csdn.net/questions/346759?sort=id  https://github.com/google/glog/issues/83

简单的Demo:

 #include <windows.h>
#include <glog/logging.h> int main(int argc, char *argv[]){ // init glog FLAGS_logbufsecs =;  //缓冲区超时,超过30秒,自动刷入log文件,设置为0是实时打印
FLAGS_max_log_size =;  //最大日志大小(MB) GLOG_logtostderr = false; //默认为false ,设置为true,log定向到stderr google::InitGoogleLogging(argv[]);
google::SetLogDestination(google::GLOG_INFO, "./logs/info_");
google::SetLogDestination(google::GLOG_WARNING, "./logs/warning_");
google::SetLogDestination(google::GLOG_ERROR, "./logs/error_"); LOG(INFO) << "My Info";
LOG(WARNING) << "My WARNING";
LOG(ERROR) << "My Error"; return ;
}

references:

http://mengjh.blog.51cto.com/2860827/546766

http://www.cnblogs.com/tianyajuanke/archive/2013/02/22/2921850.html

上一篇:OpenStack Horizon创建虚拟机时增加虚拟机OS用户


下一篇:[LeetCode] Number of Islands II 岛屿的数量之二