81 lines
1.5 KiB
C++
81 lines
1.5 KiB
C++
#ifndef LOG_H
|
|
#define LOG_H
|
|
|
|
#include "spdlog/spdlog.h"
|
|
#include <QDebug>
|
|
#include <QString>
|
|
|
|
#define ISINIT \
|
|
if (!isInit) { \
|
|
qDebug() << "Log not initialized!"; \
|
|
return; \
|
|
}
|
|
|
|
class Log {
|
|
public:
|
|
Log();
|
|
static void init();
|
|
|
|
template <typename T>
|
|
static void info(const T& msg)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_INFO(logger, msg);
|
|
}
|
|
|
|
template <typename... Args>
|
|
static void info(Args... args)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_INFO(logger, args...);
|
|
}
|
|
|
|
template <typename T>
|
|
static void warn(const T& msg)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_WARN(logger, msg);
|
|
}
|
|
|
|
template <typename... Args>
|
|
static void warn(Args... args)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_WARN(logger, args...);
|
|
}
|
|
|
|
template <typename T>
|
|
static void error(const T& msg)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_ERROR(logger, msg);
|
|
}
|
|
|
|
template <typename... Args>
|
|
static void error(Args... args)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_ERROR(logger, args...);
|
|
}
|
|
|
|
template <typename T>
|
|
static void critical(const T& msg)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_CRITICAL(logger, msg);
|
|
}
|
|
|
|
template <typename... Args>
|
|
static void critical(Args... args)
|
|
{
|
|
ISINIT
|
|
SPDLOG_LOGGER_CRITICAL(logger, args...);
|
|
}
|
|
|
|
private:
|
|
static std::shared_ptr<spdlog::logger> logger;
|
|
static bool isInit;
|
|
};
|
|
|
|
#endif // LOG_H
|