glog官方地址:
https://code.google.com/p/google-glog/
glog作用:日志库
安装方法
./configure
make
make install
Hello world
foo_1.cpp
#include <glog/logging.h>
int main(int argc,char* argv[]) {
// If glog is used to parse the command line
// google::ParseCommandLineFlags(&argc, &argv, true);
// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);
FLAGS_log_dir = "./log";
LOG(INFO) << "hello world";
return 0;
}
g++ -o foo_1 -lglog foo_1.cpp
运行后会在log目录下生成日志文件。
FLAGS_log_dir设置日志输出目录。