glog使用
程序员文章站
2022-03-20 13:58:27
...
- 使用glog可以帮助输出调试信息
int main(int argc, char* argv[])
{
string home = "./log/"; //要先创建此目录,否则运行报错.
google::InitGoogleLogging(argv[0]);
string info_log = home + "master_info_";
google::SetLogDestination(google::INFO, info_log.c_str());
string warning_log = home + "master_warning_";
google::SetLogDestination(google::WARNING, warning_log.c_str());
string error_log = home + "master_error_";
google::SetLogDestination(google::ERROR, error_log.c_str());
string fatal_log = home + "master_fatal_";
google::SetLogDestination(google::FATAL, fatal_log.c_str());
// You can specify one of the following severity levels (in increasing order of severity)
LOG(INFO) << "info";
LOG(WARNING) << "warning";
LOG(ERROR) << "error";
LOG(FATAL) << "fatal"; // Logging a FATAL message terminates the program (after the message is logged)!
return 0;
}
推荐阅读