http://www.yeolar.com/note/2014/12/20/glog/
https://blog.csdn.net/qq_24889575/article/details/83003092
#include<string>
#include<iostream>
#include"glog/logging.h"
#include"glog/raw_logging.h"
int main(int argc,char** argv)
{
FLAGS_log_dir="./log";
// FLAGS_logtostderr = 1;//输出到控制台
google::InitGoogleLogging(argv[0]);//初始化
std::string test = "this is test";
int i = 2,number = 8;
LOG(INFO)<<"it is info";
LOG_IF(INFO,number > 10)<<"number > 10";
LOG_IF(INFO,number < 10)<<"number < 10";
for(i=0;i<20;i++)
{
LOG_EVERY_N(INFO,5)<<"logi"<<i;
}
LOG(WARNING)<<"it is error info";
LOG(ERROR)<<"it is error info";
DLOG(INFO)<<"it is debug mode";
DLOG_IF(INFO,number > 10)<<"debug number > 10";
RAW_LOG(INFO,"it is pthread log");
google::ShutdownGoogleLogging();
return 0;
}
编译指令:
g++ test_main.cpp -lglog -lpthread -o test