1 Star 0 Fork 0

蝎子莱莱xo/cpp_projects

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
log.hpp 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
lmx-xo 提交于 1年前 . 顶层makefile
#pragma once
#include "util.hpp"
namespace ns_log
{
using namespace ns_util;
using std::cout;
using std::string;
//日志等级,枚举类型,实际就是整数
enum {
INFO,
DEBUG,
WARNING,
ERROR,
FATAL
};
inline std::ostream& Log(const string& level, const string& file_name, int line)
{
//添加日志等级
string message = "[";
message += level;
message += "]";
//添加文件名
message += "[";
message += file_name;
message += "]";
//添加报错行
message += "[";
message += line;
message += "]";
//添加时间戳
message += "[";
message += TimeUtil::GetTimeStamp();
message += "]";
//将message放入cout缓冲区
cout << message; //不适用endl刷新缓冲区
return cout;
}
//在使用日志接口时,不想传文件名和行数信息,可以使用宏来替代Log函数
#define LOG(level) Log(#level, __FILE__, __LINE__)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/lmx-xo/cpp_projects.git
git@gitee.com:lmx-xo/cpp_projects.git
lmx-xo
cpp_projects
cpp_projects
master

搜索帮助