mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
client logger
move over to qt signals that are processed in mainwindow
This commit is contained in:
+22
-1
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <QMainWindow>
|
||||
#include <QWidget>
|
||||
#include <nlohmann/json.hpp>
|
||||
@@ -18,6 +17,14 @@ using json = nlohmann::json;
|
||||
return new client(api, parent); \
|
||||
}
|
||||
|
||||
#define LOG_SRC_LOC(level, msg) emit log_signal(__FILE__, __LINE__, __FUNCTION__, (int)level, msg)
|
||||
#define LOG_TRACE(msg) LOG_SRC_LOC(Log_level_enum::trace, msg)
|
||||
#define LOG_DEBUG(msg) LOG_SRC_LOC(Log_level_enum::debug, msg)
|
||||
#define LOG_INFO(msg) LOG_SRC_LOC(Log_level_enum::info, msg)
|
||||
#define LOG_WARN(msg) LOG_SRC_LOC(Log_level_enum::warn, msg)
|
||||
#define LOG_ERROR(msg) LOG_SRC_LOC(Log_level_enum::err, msg)
|
||||
#define LOG_CRITICAL(msg) LOG_SRC_LOC(Log_level_enum::critical, msg)
|
||||
|
||||
/**
|
||||
* @brief Base class for client UIs
|
||||
*/
|
||||
@@ -25,6 +32,17 @@ class UI_base : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Log_level_enum : int
|
||||
{
|
||||
trace,
|
||||
debug,
|
||||
info,
|
||||
warn,
|
||||
err,
|
||||
critical,
|
||||
off,
|
||||
n_levels
|
||||
};
|
||||
/**
|
||||
* @brief Construct a new ui base object
|
||||
*
|
||||
@@ -320,6 +338,9 @@ class UI_base : public QMainWindow
|
||||
*/
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void log_signal(const char *filename_in, int line_in, const char *funcname_in, int level, QString msg);
|
||||
|
||||
private:
|
||||
Web_socket_wrapper *m_web_socket;
|
||||
QString m_name;
|
||||
|
||||
Reference in New Issue
Block a user