美文网首页
glog的使用简介

glog的使用简介

作者: loki528 | 来源:发表于2019-03-18 11:16 被阅读0次

    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
    

    写的不错的一个总结
    https://www.cnblogs.com/hiloves/p/6009707.html

    相关文章

      网友评论

          本文标题:glog的使用简介

          本文链接:https://www.haomeiwen.com/subject/dzcvmqtx.html