1 Star 0 Fork 0

wangzhankun/untrunc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
log.h 811 Bytes
一键复制 编辑 原始数据 按行查看 历史
#ifndef LOG_H
#define LOG_H
#include <iostream>
#include <string>
class Logger {
public:
enum Level { SILENT = 0, ERROR = 1, INFO = 3, DEBUG = 4 };
Level level;
static Level log_level;
Logger(Level _level): level(_level) {}
template<class T> Logger &operator<<(const T &msg) {
if(level <= Logger::log_level)
std::cout << msg;
return *this;
}
// define an operator<< to take in std::endl
typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
typedef CoutType& (*StandardEndLine)(CoutType&);
Logger& operator<<(StandardEndLine manip) {
if(level <= Logger::log_level)
std::cout << std::endl;
return *this;
}
};
class Log {
public:
static Logger error;
static Logger info;
static Logger debug;
static void flush() { std::cout << std::flush; }
};
#endif // LOG_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangzhankun/untrunc.git
git@gitee.com:wangzhankun/untrunc.git
wangzhankun
untrunc
untrunc
master

搜索帮助