mirror of https://github.com/WerWolv/ImHex.git
sys: Added time and source to logger output
This commit is contained in:
parent
c2bcbfb1e0
commit
df1d302bcb
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/color.h>
|
||||
#include <fmt/chrono.h>
|
||||
|
||||
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<typename S, typename... Args>
|
||||
void print(const fmt::text_style &ts, const S &fmt, const Args &...args) {
|
||||
printPrefix();
|
||||
if (isRedirected())
|
||||
fmt::print(getDestination(), fmt::runtime(fmt), args...);
|
||||
else
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include <hex.hpp>
|
||||
|
||||
#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; } \
|
||||
|
|
|
@ -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 ()
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
|
@ -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})
|
||||
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||
|
|
|
@ -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 ()
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue