aboutsummaryrefslogtreecommitdiffstats
path: root/src/module/sdk/Log.h
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-10-23 06:29:25 +0000
committersaturneric <[email protected]>2023-10-23 06:29:25 +0000
commit31fc827672a131da020c4b4a0c3c8a145d477835 (patch)
treea825cdbf87d69d7449d00f7360c797e755e8f783 /src/module/sdk/Log.h
parentfix: improve the stability of thread system (diff)
downloadGpgFrontend-31fc827672a131da020c4b4a0c3c8a145d477835.tar.gz
GpgFrontend-31fc827672a131da020c4b4a0c3c8a145d477835.zip
feat: improve project structure and add GRT for modules
Diffstat (limited to '')
-rw-r--r--src/module/sdk/Log.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/module/sdk/Log.h b/src/module/sdk/Log.h
new file mode 100644
index 00000000..57cd3cf8
--- /dev/null
+++ b/src/module/sdk/Log.h
@@ -0,0 +1,86 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend 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, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend 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 GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#include "module/GpgFrontendModule.h"
+
+namespace spdlog {
+class logger;
+}
+
+using Logger = std::shared_ptr<spdlog::logger>;
+
+/**
+ * @brief
+ *
+ */
+void GPGFRONTEND_MODULE_EXPORT InitModuleLoggingSystem();
+
+/**
+ * @brief
+ *
+ */
+void GPGFRONTEND_MODULE_EXPORT ShutdownModuleLoggingSystem();
+
+/**
+ * @brief
+ *
+ */
+Logger GetModuleLogger();
+
+#define MODULE_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(GetModuleLogger, ...)
+#define MODULE_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(GetModuleLogger, ...)
+#define MODULE_LOG_INFO(...) SPDLOG_LOGGER_INFO(GetModuleLogger, ...)
+#define MODULE_LOG_WARN(...) SPDLOG_LOGGER_WARN(GetModuleLogger, ...)
+#define MODULE_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(GetModuleLogger, ...)
+
+template <typename... Args>
+void ModuleLogTrace(const char* fmt, const Args&... args) {
+ SPDLOG_LOGGER_TRACE(GetModuleLogger(), fmt, args...);
+}
+
+template <typename... Args>
+void ModuleLogDebug(const char* fmt, const Args&... args) {
+ SPDLOG_LOGGER_DEBUG(GetModuleLogger(), fmt, args...);
+}
+
+template <typename... Args>
+void ModuleLogInfo(const char* fmt, const Args&... args) {
+ SPDLOG_LOGGER_INFO(GetModuleLogger(), fmt, args...);
+}
+
+template <typename... Args>
+void ModuleLogWarn(const char* fmt, const Args&... args) {
+ SPDLOG_LOGGER_WARN(GetModuleLogger(), fmt, args...);
+}
+
+template <typename... Args>
+void ModuleLogError(const char* fmt, const Args&... args) {
+ SPDLOG_LOGGER_ERROR(GetModuleLogger(), fmt, args...);
+}