You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cigarette/Cigarette/Logthread.h

72 lines
1.5 KiB
C++

#pragma once
#include <QDialog>
class CLog : public QObject
{
Q_OBJECT
public:
enum CLOG_TYPE
{
STARTAPP,
STARTWORK,
PAUSEWORK,
UNLOCK,
DEBUGMODE,
UNKICKMODE,
SETTING,
CLEANPIC,
DOUBLECLICK,
ROTATEPIC,
PLCSETTING,
ALARM
};
//Q_DECLARE_FLAGS(CLOG_TYPE_Flags, CLOG_TYPE)
Q_ENUM(CLOG_TYPE)
struct LogConfig
{
bool isRecord2File;
int level;
};
CLog();
void setLogType(const CLog::CLOG_TYPE& type);
// CLog::CLOG_TYPE getLogType() { return logType; }
//void startClog();
//void doWork();
static bool init(CLog::LogConfig& logConfig);
static bool createDir(QString dirPath);
static void log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...);
static void log(CLOG_TYPE nType, const char* data, ...);
public slots:
void recMegFromCigarette(QString);
private:
static QString getTypeDesc(CLOG_TYPE type);
private:
static bool isRecord2File;
static bool isFileReady;
};
#ifdef Q_OS_WIN
#define FILE_SEPARATOR '\\'
#else
#define FILE_SEPARATOR '/'
#endif
#define FUNC_SEPARATOR '::'
#ifndef QT_NO_DEBUG
#define __FILENAME__ (strrchr(__FILE__, FILE_SEPARATOR) ? (strrchr(__FILE__, FILE_SEPARATOR) + 1):__FILE__)
#define __FUNNAME__ (strrchr(__FUNCTION__,FUNC_SEPARATOR)?(strrchr(__FUNCTION__, FUNC_SEPARATOR) + 1):__FUNCTION__)
#else
#define __FILENAME__ NULL
#define __FUNNAME__ NULL
#endif
#define CLOG_INFO(...) CLog::log(CLog::STARTAPP, __VA_ARGS__)