#ifndef LOGGER_H
#define LOGGER_H

#include <QObject>
#include <QMutex>
#include <QHash>

class Logger : public QObject
{
    Q_OBJECT
    enum Level
    {
        Info = 0,
        Warning,
        Error,
        Debug
    };

public:
    static Logger *instance();
public:
    Logger(const Logger*)=delete;
    Logger *operator =(const Logger*)=delete;
public:
    void init();
public:
    QString registerName(QObject *, QString);
public:
    void info(QString);
    void warn(QString);
    void error(QString);
    void debug(QString);
private:
    explicit Logger(QObject *parent = nullptr);
    ~Logger();
private:
    QString model(QObject *obj = nullptr);
    QString date();
    QString dateTime();
    void log(QString content, QString model = QString());
private:
    static Logger           *m_oInstance;
    static QMutex            m_oMutex;
private:
    int                      m_iHandle;
    int                      m_iLevel;
    int                      m_iCurrentLevel;
    QHash<QObject*, QString> m_oRegister;

};
#define LOGGER Logger::instance()
#endif // LOGGER_H
