diff --git a/lib/libimhex-rs/proc_macros/CMakeLists.txt b/lib/libimhex-rs/proc_macros/CMakeLists.txt index 53a1aa56f..2c34ee383 100644 --- a/lib/libimhex-rs/proc_macros/CMakeLists.txt +++ b/lib/libimhex-rs/proc_macros/CMakeLists.txt @@ -25,7 +25,7 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden") endif() -add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME}) +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") if (NOT TARGET libimhex) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libimhex ${CMAKE_CURRENT_BINARY_DIR}/plugins/libimhex) diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index e18dee512..7149146b4 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -152,6 +152,8 @@ if (APPLE) set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} source/helpers/paths_mac.mm) endif () +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") + add_library(libimhex SHARED ${LIBIMHEX_SOURCES}) set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/lib/libimhex/include/hex/helpers/logger.hpp b/lib/libimhex/include/hex/helpers/logger.hpp index 1fbf0149b..943df189e 100644 --- a/lib/libimhex/include/hex/helpers/logger.hpp +++ b/lib/libimhex/include/hex/helpers/logger.hpp @@ -1,10 +1,22 @@ #pragma once +#include + #include #include +#include namespace hex::log { + namespace { + + void printPrefix() { + const auto now = fmt::localtime(std::chrono::system_clock::now()); + fmt::print("[{0:%H:%M:%S}] [{1}] ", now, IMHEX_PROJECT_NAME); + } + + } + FILE *getDestination(); bool isRedirected(); @@ -15,6 +27,7 @@ namespace hex::log { template void print(const fmt::text_style &ts, const S &fmt, const Args &...args) { + printPrefix(); if (isRedirected()) fmt::print(getDestination(), fmt::runtime(fmt), args...); else diff --git a/lib/libimhex/include/hex/plugin.hpp b/lib/libimhex/include/hex/plugin.hpp index ee7fed788..d850f916d 100644 --- a/lib/libimhex/include/hex/plugin.hpp +++ b/lib/libimhex/include/hex/plugin.hpp @@ -6,9 +6,9 @@ #include -#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(IMHEX_PLUGIN_NAME, name, author, description) +#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(name, author, description) -#define IMHEX_PLUGIN_SETUP_IMPL(namespaceName, name, author, description) \ +#define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \ extern "C" [[gnu::visibility("default")]] const char *getPluginName() { return name; } \ extern "C" [[gnu::visibility("default")]] const char *getPluginAuthor() { return author; } \ extern "C" [[gnu::visibility("default")]] const char *getPluginDescription() { return description; } \ diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 38dafe82f..dc38a73c7 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -22,6 +22,8 @@ set_target_properties(main PROPERTIES CXX_VISIBILITY_PRESET hidden POSITION_INDEPENDENT_CODE ON) +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") + if (WIN32) target_link_libraries(main PUBLIC libimhex wsock32 ws2_32 Dwmapi.lib) else () diff --git a/plugins/builtin/CMakeLists.txt b/plugins/builtin/CMakeLists.txt index fdf96b818..869e7b48c 100644 --- a/plugins/builtin/CMakeLists.txt +++ b/plugins/builtin/CMakeLists.txt @@ -70,5 +70,5 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden") endif() -add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME}) +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) \ No newline at end of file diff --git a/plugins/example_cpp/CMakeLists.txt b/plugins/example_cpp/CMakeLists.txt index 453d84656..fc4f4aebc 100644 --- a/plugins/example_cpp/CMakeLists.txt +++ b/plugins/example_cpp/CMakeLists.txt @@ -25,5 +25,5 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden") endif() -add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME}) +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) \ No newline at end of file diff --git a/plugins/example_rust/CMakeLists.txt b/plugins/example_rust/CMakeLists.txt index 71911c330..1ba0f996a 100644 --- a/plugins/example_rust/CMakeLists.txt +++ b/plugins/example_rust/CMakeLists.txt @@ -38,4 +38,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES RUST_PROJECT 1) set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE Rust) set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) -add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME}) \ No newline at end of file +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") diff --git a/plugins/windows/CMakeLists.txt b/plugins/windows/CMakeLists.txt index 427d294d8..8fe177857 100644 --- a/plugins/windows/CMakeLists.txt +++ b/plugins/windows/CMakeLists.txt @@ -5,7 +5,7 @@ project(windows) # Add your source files here # if (WIN32) - + add_library(${PROJECT_NAME} SHARED source/plugin_windows.cpp @@ -35,7 +35,7 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden") endif() - add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME}) + add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) endif () \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 32400d103..f3656ab16 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,7 @@ project(unit_tests) enable_testing() +add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") add_custom_target(unit_tests) add_subdirectory(common)