mirror of
https://github.com/ApfelTeeSaft/WV-Core.git
synced 2026-08-26 19:43:26 +00:00
Logger
This commit is contained in:
+13
-2
@@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_library(WVCore STATIC
|
||||
src/Test.cpp
|
||||
src/temp.cpp
|
||||
)
|
||||
|
||||
target_include_directories(WVCore PUBLIC
|
||||
@@ -13,4 +13,15 @@ target_include_directories(WVCore PUBLIC
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
target_compile_features(WVCore PUBLIC cxx_std_20)
|
||||
target_compile_features(WVCore PUBLIC cxx_std_20)
|
||||
|
||||
# Add platform-specific preprocessor definitions
|
||||
if(WIN32)
|
||||
target_compile_definitions(WVCore PUBLIC PLATFORM_WINDOWS)
|
||||
elseif(APPLE)
|
||||
target_compile_definitions(WVCore PUBLIC PLATFORM_MACOS)
|
||||
elseif(UNIX)
|
||||
target_compile_definitions(WVCore PUBLIC PLATFORM_LINUX)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown platform!")
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
|
||||
#define LOG_COLOR_RESET "\x1b[0m"
|
||||
#define LOG_COLOR_APP_WARN "\x1b[93m"
|
||||
#define LOG_COLOR_APP_ERROR "\x1b[91m"
|
||||
#define LOG_COLOR_ENGINE_LOG "\x1b[32m"
|
||||
#define LOG_COLOR_ENGINE_WARN "\x1b[33m"
|
||||
#define LOG_COLOR_ENGINE_ERROR "\x1b[41m"
|
||||
|
||||
namespace WillowVox
|
||||
{
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
template <typename... Args>
|
||||
static void Log(const char* message, Args... args)
|
||||
{
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm now;
|
||||
|
||||
#ifdef _WIN32
|
||||
localtime_s(&now, &t);
|
||||
#else
|
||||
localtime_r(&t, &now);
|
||||
#endif
|
||||
|
||||
printf(LOG_COLOR_RESET "[%02d:%02d:%02d] ", now.tm_hour, now.tm_min, now.tm_sec);
|
||||
printf(message, args...);
|
||||
printf(LOG_COLOR_RESET "\n");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace WillowVox::Core
|
||||
{
|
||||
void Test();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <core/Logger.h>
|
||||
@@ -1,11 +0,0 @@
|
||||
#include <core/Test.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace WillowVox::Core
|
||||
{
|
||||
void Test()
|
||||
{
|
||||
std::cout << "Running Core Update Test..." << std::endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user