作者:Joke-晓 | 来源:互联网 | 2023-10-12 19:14
windows下:1,下载地址:https:github.comgoogleglog点击DownloadZIP下载即可。2.解压,打开google-glog.sln编译,生成deb
windows下:
1, 下载地址: https://github.com/google/glog

点击Download ZIP 下载即可。
2. 解压,打开google-glog.sln 编译,生成debug下的lib和dll文件;
3. 将
新建一个基于console 的demo工程,将lib和dll 拷贝到工程下,将windows目录下的glog头文件拷贝到工程下(目录一起),代码如下:
// glog_test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "glog/logging.h"
#include
#include
using namespace std;
#pragma comment(lib,"libglog.lib")
int _tmain(int argc, char* argv[])
{
// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);
google::SetLogDestination(google::INFO,"E://");
// 设置日志路径 INFO WARNING ERROR FATAL
// ...
char str[20] = "hello log!";
LOG(INFO) << "Found " << google::COUNTER <LOG(INFO) << str ;//<< " COOKIEs";
LOG(WARNING) << "warning test"; // 会输出一个Warning日志
LOG(ERROR) << "error test";//会输出一个Error日志
while(1);
return 0;
}


4. 编译运行,看到E盘目录下的日志文件。

完成。