generallib/general/inc/loger.h

45 lines
968 B
C
Raw Normal View History

2019-12-21 10:50:15 +00:00
//
// Created by bt110 on 2019/8/19.
//
#ifndef CPP11FEATURETEST_LOGER_H
#define CPP11FEATURETEST_LOGER_H
#include <stdio.h>
#include <string>
#include <time.h>
#include <fstream>
#include <iostream>
using namespace std;
2021-12-15 08:19:59 +00:00
typedef enum Mode{
Mode_Daily, // 每天保存一次日志
MODE_Monthly, // 每个月保存一次日志
2021-12-15 09:34:02 +00:00
MODE_Weekly, // 每周保存一次日志
MODE_Size // 根据已存储的容量来保存日志
2021-12-15 08:19:59 +00:00
}ESaveMode;
2021-12-15 09:34:02 +00:00
class Loger {
2021-12-15 08:19:59 +00:00
public:
2021-12-15 09:34:02 +00:00
Loger(string path,string prefix);
2021-12-15 08:19:59 +00:00
#define DEBUG_FILE_POSITION __FILE__,__LINE__
int Debug(string,string,int);
int Log();
int LogFile();
void operator+(const string&);
void operator<<(const string&);
2021-12-15 09:34:02 +00:00
private:
string mPath;
string mPrefix;
string mCurrentPath;
FILE *mFile; // 日志文件
ESaveMode mMode; // 工作模式
string mCurrentDate; // 当天
bool mValid;
};
2019-12-21 10:50:15 +00:00
#endif //CPP11FEATURETEST_LOGER_H