Fixing Logging. DevPlayground compiles and runs on Linux now.

This commit is contained in:
Thorben Höhne 2025-02-18 00:50:10 +01:00
parent defa41b42a
commit d6362a62df
8 changed files with 179 additions and 39 deletions

56
.gitignore vendored
View File

@ -6,16 +6,60 @@ external/
# Frequently edited tests
Tests/TestProject/
# CMake Build Files
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles/
CMakeScripts/
Testing/
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps/
CMakeUserPresets.json
build/
# Exclude files
# C++
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Temporary excludes
Core/private/Math/
Matrix4.h
IntVector4.h
Vector4.h
############################################################################################
## Ignore Visual Studio temporary files, build results, and

89
.vscode/settings.json vendored
View File

@ -3,8 +3,8 @@
"C_Cpp.loggingLevel": "Error",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.includePath": [
"${workspaceFolder}/Engine/Source/Runtime",
"${workspaceFolder}/Engine/Source/ThirdParty"
"${workspaceFolder}/Engine/Source/Runtime/",
"${workspaceFolder}/Engine/Source/ThirdParty/"
],
"C_Cpp.default.browse.path": [
@ -13,10 +13,93 @@
],
"C_Cpp.default.browse.databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db",
"files.associations": {
"cstdint": "cpp"
"cstdint": "cpp",
"chrono": "cpp",
"string": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"charconv": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"expected": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"hash_map": "cpp",
"hash_set": "cpp",
"format": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stdfloat": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"text_encoding": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
},
"C_Cpp.default.defines": [
"P_LINUX_BUILD",
"__SSE__",
],
"cmake.sourceDirectory": "/home/morthaine/Development/PhanesEngine/DevPlayground",
}

View File

@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15...3.30)
project(DevPlayground)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../Engine/Source/Runtime ${CMAKE_BINARY_DIR}/Engine)

View File

@ -22,5 +22,8 @@ ${StartingPointPCH}
add_compile_definitions(P_LINUX_BUILD)
add_compile_definitions(P_DEBUG)
# fmt for spdlog. It uses the external module which needs to be linked manually
find_package(fmt)
target_link_libraries(PhanesCore fmt::fmt)
target_include_directories(PhanesCore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)

View File

@ -6,13 +6,19 @@
namespace Phanes::Core::Logging
{
static Phanes::Ref<spdlog::logger> _PEngineLogger;
static Phanes::Ref<spdlog::logger> _PAppLogger;
class Logger {
void Init();
public:
inline std::shared_ptr<spdlog::logger>& PEngineLogger() { return _PEngineLogger; };
inline std::shared_ptr<spdlog::logger>& PAppLogger() { return _PAppLogger; };
static void Init();
static std::shared_ptr<spdlog::logger>& PEngineLogger() { return _PEngineLogger; }
static std::shared_ptr<spdlog::logger>& PAppLogger() { return _PAppLogger; }
private:
static std::shared_ptr<spdlog::logger> _PEngineLogger;
static std::shared_ptr<spdlog::logger> _PAppLogger;
};
}
@ -22,18 +28,18 @@ namespace PLog = Phanes::Core::Logging; // User Macros
// Default logger
#define PENGINE_LOG_TRACE(...) ::Phanes::Core::Logging::PEngineLogger()->trace(__VA_ARGS__)
#define PENGINE_LOG_INFO(...) ::Phanes::Core::Logging::PEngineLogger()->info(__VA_ARGS__)
#define PENGINE_LOG_WARN(...) ::Phanes::Core::Logging::PEngineLogger()->warn(__VA_ARGS__)
#define PENGINE_LOG_ERROR(...) ::Phanes::Core::Logging::PEngineLogger()->error(__VA_ARGS__)
#define PENGINE_LOG_FATAL(...) ::Phanes::Core::Logging::PEngineLogger()->critical(__VA_ARGS__)
#define PENGINE_LOG_TRACE(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->trace(__VA_ARGS__)
#define PENGINE_LOG_INFO(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->info(__VA_ARGS__)
#define PENGINE_LOG_WARN(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->warn(__VA_ARGS__)
#define PENGINE_LOG_ERROR(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->error(__VA_ARGS__)
#define PENGINE_LOG_FATAL(...) ::Phanes::Core::Logging::Logger::PEngineLogger()->critical(__VA_ARGS__)
#define PAPP_LOG_TRACE(...) ::Phanes::Core::Logging::PAppLogger()->trace(__VA_ARGS__)
#define PAPP_LOG_INFO(...) ::Phanes::Core::Logging::PAppLogger()->info(__VA_ARGS__)
#define PAPP_LOG_WARN(...) ::Phanes::Core::Logging::PAppLogger()->warn(__VA_ARGS__)
#define PAPP_LOG_ERROR(...) ::Phanes::Core::Logging::PAppLogger()->error(__VA_ARGS__)
#define PAPP_LOG_FATAL(...) ::Phanes::Core::Logging::PAppLogger()->critical(__VA_ARGS__)
#define PAPP_LOG_TRACE(...) ::Phanes::Core::Logging::Logger::PAppLogger()->trace(__VA_ARGS__)
#define PAPP_LOG_INFO(...) ::Phanes::Core::Logging::Logger::PAppLogger()->info(__VA_ARGS__)
#define PAPP_LOG_WARN(...) ::Phanes::Core::Logging::Logger::PAppLogger()->warn(__VA_ARGS__)
#define PAPP_LOG_ERROR(...) ::Phanes::Core::Logging::Logger::PAppLogger()->error(__VA_ARGS__)
#define PAPP_LOG_FATAL(...) ::Phanes::Core::Logging::Logger::PAppLogger()->critical(__VA_ARGS__)
#else

View File

@ -1,6 +1,13 @@
#include "Core/Logging/Logging.h"
void Phanes::Core::Logging::Init()
namespace Phanes::Core::Logging
{
std::shared_ptr<spdlog::logger> Logger::_PEngineLogger;
std::shared_ptr<spdlog::logger> Logger::_PAppLogger;
} // namespace Phanes::Core::Logging
void Phanes::Core::Logging::Logger::Init()
{
spdlog::set_pattern("%^[%n][%T][%l]:%$ %v");

View File

@ -7,15 +7,12 @@ extern Phanes::Core::Application::PhanesProject* Phanes::Core::Application::Crea
int main(int argc, char** argv)
{
Phanes::Core::Logging::Init();
Phanes::Core::Logging::Logger::Init();
PENGINE_LOG_INFO("Logger initialized!");
PENGINE_LOG_INFO("Welcome to PhanesEngine!");
auto phanes_game = Phanes::Core::Application::CreatePhanesGame();
PENGINE_LOG_INFO("Loading project {0}...", phanes_game->GetName());
phanes_game->Run();
delete phanes_game;

View File

@ -1,24 +1,25 @@
#include "Core/StartingPoint/StartingPoint.h"
#include "Core/Logging/Logging.h"
static void IdleMsg()
{
std::cout << "\n\nWelcome to PhanesEngine!" << std::endl << std::endl;
std::cout << "\nWelcome to PhanesEngine!\n";
std::this_thread::sleep_for(std::chrono::seconds(5));
std::cout << "It's silent..." << std::endl << std::endl;
std::cout << "It's silent...\n";
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << "To silent." << std::endl;
std::cout << "To silent.\n";
std::this_thread::sleep_for(std::chrono::seconds(5));
std::cout << "\nI will go now" << std::endl;
std::cout << "I will go now\n";
std::this_thread::sleep_for(std::chrono::seconds(4));
std::cout << "\nGood by!" << std::endl;
std::cout << "Good by!\n\n";
std::this_thread::sleep_for(std::chrono::seconds(3));
}
@ -27,11 +28,13 @@ static void IdleMsg()
Phanes::Core::Application::PhanesProject::PhanesProject(std::string _ProjectName)
: projectName(_ProjectName)
{};
{
PAPP_LOG_INFO("Loading project: {0}", this->GetName());
};
Phanes::Core::Application::PhanesProject::~PhanesProject()
{
this->projectName = "Unnamed Project";
PAPP_LOG_INFO("Unloading project: {0}", this->GetName());
};
std::string Phanes::Core::Application::PhanesProject::GetName()