User operation log, v1

This commit is contained in:
Krad
2021-11-19 15:36:12 +08:00
parent bca10e3e60
commit 99754ab84f
9 changed files with 144 additions and 44 deletions

View File

@@ -0,0 +1,62 @@
//
// Created by Krad on 2021/11/19.
//
#ifndef GUI_USEROPERATIONLOG_H
#define GUI_USEROPERATIONLOG_H
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#define USER_OPERATIONS()\
ADD_OPERATION(Login)\
ADD_OPERATION(Logout)\
ADD_OPERATION(ChangePassword)\
ADD_OPERATION(ChangeUserName)\
ADD_OPERATION(AddPatient)\
ADD_OPERATION(ChangePatientInfo)\
ADD_OPERATION(DeletePatient)\
ADD_OPERATION(SelectPatient)\
ADD_OPERATION(StartRefresh)\
ADD_OPERATION(Stop)\
ADD_OPERATION(StartPreview)\
ADD_OPERATION(StartScan)\
ADD_OPERATION(ConfirmError)\
#define LOG_USER_OPERATION(...)\
UserOperationLog::Default()->log(__VA_ARGS__);
enum UserOperation{
#define ADD_OPERATION(name) name,\
USER_OPERATIONS()
#undef ADD_OPERATION
};
class UserOperationLog {
public:
UserOperationLog(){}
~UserOperationLog(){
if (logFile.isOpen())
{
logFile.flush();
logFile.close();
}
}
void init();
static UserOperationLog* Default(){
static UserOperationLog d;
return &d;
}
void log(UserOperation operation, bool processing = false);
private:
QString currentFileName;
QFile logFile;
QTextStream out;
};
#endif //GUI_USEROPERATIONLOG_H