glog是google出品的一个C++日志库
CentOS下glog的使用简介
安装依赖的库
yum install glog-devel.x86_64
yum install gflags-devel.x86_64
编写代码client.cpp
#include <iostream>
#include <glog/logging.h>
using namespace std;
static void InitLog(const char* cmd)
{
FLAGS_logbufsecs = 0;
google::InitGoogleLogging(cmd);
FLAGS_log_dir = "/root/log/";
}
int main(int argc, char** argv)
{
InitLog(argv[0]);
LOG(INFO)<<"Hello world glog";
cout<<"hello world"<<endl;
return 0;
}
编写Makefile
client:client.cpp
g++ -g client.cpp -o client -lglog
网友评论