QtHPConnect/include/errorhandler.h

75 lines
1.7 KiB
C
Raw Normal View History

2020-02-02 18:13:27 +01:00
/*
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
* Copyright (c) 2020 Ian Gebbie.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 or later.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2019-02-10 14:32:15 +01:00
#ifndef ERRORHANDLER_H
#define ERRORHANDLER_H
#include <QObject>
2019-02-10 14:43:00 +01:00
#include <QFile>
#include <QTextStream>
#include <QMutexLocker>
#include <QDateTime>
#include <QDebug>
enum ErrLevel {
L0, //abort
L1, //fault
L2, //warning
L3,
L4,
L7 //information
};
2019-02-17 17:24:52 +01:00
typedef enum {
ERR_SUCCESS = 0, // Must be equal to ERR_HPLIBS_GENERIC_FIRST
ERR_MALLOC,
ERR_INVALID_HANDLE,
ERR_INVALID_PARAMETER,
ERR_INVALID_MODEL,
ERR_LIBRARY_INIT,
ERR_LIBRARY_EXIT,
ERR_LIBRARY_CONFIG_VERSION,
ERR_FILE_FIRST,
ERR_FILE_FILENAME,
ERR_FILE_LAST
} hp_error;
2019-02-10 14:43:00 +01:00
class errorHandler {
private:
QObject * pParent;
QMutex m_lineLoggerMutex;
QString getLogFileName();
int writeLog(QString);
int writeStatus(QString);
int writeChatter(QString);
2019-02-10 14:32:15 +01:00
public:
errorHandler();
2019-02-10 14:43:00 +01:00
errorHandler(QObject *);
2019-09-15 17:23:44 +02:00
~errorHandler();
2019-02-10 14:43:00 +01:00
int error(ErrLevel, int, QString, QString Data);
int dump(uint8_t *, int);
2019-02-10 14:32:15 +01:00
};
2019-02-10 14:43:00 +01:00
#endif // ERRORHANDLER_H