Apollo中的glog
在Apollo中google glog 被广泛使用,glog 是 google 的一个 c++ 开源日志系统,轻巧灵活,入门简单,而且功能也比较完善。
1. 安装
以下是官方的安装方法,一句命令:
git clone https://github.com/google/glog.git
cd glog
./autogen.sh && ./configure && make && make install
2. 使用
2.1 菜鸟级
从一个最简单的程序开始:
#include <glog/logging.h>
int main(int argc,char* argv[])
{
google::InitGoogleLogging(argv[0]); //初始化 glog
LOG(INFO) << "Hello,GOOGLE!";
}
编译:
1. glog g++ glog_test2.cpp -lglog -lgflags -lpthread -o glog_test #编译
2. glog ./glog_test
3. glog ll /tmp