From 81ca77a464de44ac8c8ac8f0669a4230121eb1e8 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 16 May 2023 19:31:53 +0300 Subject: [PATCH] initial work on loggin class --- CMakeLists.txt | 2 +- src/Util/Log.cpp | 17 +++++++++++++++++ src/Util/Log.h | 35 +++++++++++++++++++++++++++++++++++ src/main.cpp | 4 +++- 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/Util/Log.cpp create mode 100644 src/Util/Log.h diff --git a/CMakeLists.txt b/CMakeLists.txt index edb5e4c7..acdeb680 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ add_executable(shadps4 src/Loader/Elf.cpp src/Loader/Elf.h src/GUI/ElfViewer.cpp - src/GUI/ElfViewer.h) + src/GUI/ElfViewer.h "src/Util/Log.h" "src/Util/Log.cpp") find_package(OpenGL REQUIRED) diff --git a/src/Util/Log.cpp b/src/Util/Log.cpp new file mode 100644 index 00000000..995f5892 --- /dev/null +++ b/src/Util/Log.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + + + +namespace logging { + std::vector sinks; + + int init(bool use_stdout) { + sinks.clear();//clear existing sinks + if (use_stdout)//if we use stdout window then init it as well + sinks.push_back(std::make_shared()); + + return 0;//all ok + } +} \ No newline at end of file diff --git a/src/Util/Log.h b/src/Util/Log.h new file mode 100644 index 00000000..8ee272b2 --- /dev/null +++ b/src/Util/Log.h @@ -0,0 +1,35 @@ +#pragma once + +#include + + +namespace logging { + +#define LOG_TRACE SPDLOG_TRACE +#define LOG_DEBUG SPDLOG_DEBUG +#define LOG_INFO SPDLOG_INFO +#define LOG_WARN SPDLOG_WARN +#define LOG_ERROR SPDLOG_ERROR +#define LOG_CRITICAL SPDLOG_CRITICAL + +#define LOG_TRACE_IF(flag, ...) \ + if (flag) \ + LOG_TRACE(__VA_ARGS__) +#define LOG_DEBUG_IF(flag, ...) \ + if (flag) \ + LOG_DEBUG(__VA_ARGS__) +#define LOG_INFO_IF(flag, ...) \ + if (flag) \ + LOG_INFO(__VA_ARGS__) +#define LOG_WARN_IF(flag, ...) \ + if (flag) \ + LOG_WARN(__VA_ARGS__) +#define LOG_ERROR_IF(flag, ...) \ + if (flag) \ + LOG_ERROR(__VA_ARGS__) +#define LOG_CRITICAL_IF(flag, ...) \ + if (flag) \ + LOG_CRITICAL(__VA_ARGS__) + + int init(bool use_stdout); +} diff --git a/src/main.cpp b/src/main.cpp index 8da99c6d..e910e5b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,7 @@ #include "types.h" #include "Loader/Elf.h" #include "GUI/ElfViewer.h" +#include "Util/Log.h" // This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details. #ifdef __EMSCRIPTEN__ @@ -27,7 +28,8 @@ // Main code int main(int argc, char* argv[]) { - const char* const path = argv[1]; //argument 1 is the path of self file to boot + logging::init(true);//init logging + const char* const path = argv[1]; //argument 1 is the path of self file to boot Elf* elf = new Elf; elf->Open(path);