From 655d0706a081901b2e622d9eeb959e6bda969188 Mon Sep 17 00:00:00 2001 From: "moritz.becker" Date: Mon, 6 Jul 2026 21:01:36 +0200 Subject: [PATCH] Logger added. Project settings added Logger test added --- .idea/.gitignore | 10 ++ .idea/ETACG.iml | 2 + .idea/editor.xml | 346 ++++++++++++++++++++++++++++++++++++++++++ .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/vcs.xml | 7 + CMakeLists.txt | 12 +- src/Logger/LOGGER.cpp | 35 +++++ src/Logger/LOGGER.h | 33 ++++ src/main.cpp | 12 +- 10 files changed, 463 insertions(+), 9 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/ETACG.iml create mode 100644 .idea/editor.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 src/Logger/LOGGER.cpp create mode 100644 src/Logger/LOGGER.h diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/ETACG.iml b/.idea/ETACG.iml new file mode 100644 index 0000000..4c94235 --- /dev/null +++ b/.idea/ETACG.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..1798069 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,346 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6e5c38a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..0941ef5 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e3a1846..4114bcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) -project(Beskar C CXX) +project(ETACG C CXX) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Raylib-Einstellungen (sorgt dafür, dass wir nur das bauen, was wir brauchen) @@ -13,10 +13,12 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) add_subdirectory(raylib) # Dein Spiel-Executable -add_executable(Beskar src/main.cpp) +add_executable(ETACG src/main.cpp + src/Logger/logger.cpp + src/Logger/logger.h) # Verknüpfung: Dein Spiel benötigt Raylib -target_link_libraries(Beskar PRIVATE raylib) +target_link_libraries(ETACG PRIVATE raylib) # Header-Verzeichnis für Raylib damit C++ es findet -target_include_directories(Beskar PRIVATE raylib/src) \ No newline at end of file +target_include_directories(ETACG PRIVATE raylib/src) \ No newline at end of file diff --git a/src/Logger/LOGGER.cpp b/src/Logger/LOGGER.cpp new file mode 100644 index 0000000..264cbc6 --- /dev/null +++ b/src/Logger/LOGGER.cpp @@ -0,0 +1,35 @@ +// +// Created by matrx on 06.07.2026. +// + +#include "LOGGER.h" + + +namespace BESKAR { + LOGGER::LOGGER(LOGGER_TYPE loggerType, std::string prefix) { + this->type = loggerType; + this->prefix = prefix; + } + LOGGER::LOGGER(LOGGER_TYPE type, std::string filename, std::string prefix) { + this->type = type; + this->filename = filename; + this->prefix = prefix; + this->logfile.open(filename.c_str()); + } + + bool LOGGER::log(std::string msg) { + std::string tmp = std::format("LOGGER::{}::{}",this->prefix, msg); + switch (this->type) { + case LOGGER_TYPE::TERMINAL: + std::cout << tmp << std::endl; + break; + case LOGGER_TYPE::FILE: + this->logfile << tmp << std::endl ; + break; + default: + break; + } + this->filebffr.push_back(tmp); + return true; + } +} // BESKAR \ No newline at end of file diff --git a/src/Logger/LOGGER.h b/src/Logger/LOGGER.h new file mode 100644 index 0000000..cb86bd0 --- /dev/null +++ b/src/Logger/LOGGER.h @@ -0,0 +1,33 @@ +// +// Created by matrx on 06.07.2026. +// + +#ifndef ETACG_LOGGER_H +#define ETACG_LOGGER_H + +#include +#include +#include +#include +#include + +namespace BESKAR { + enum class LOGGER_TYPE { + TERMINAL = 0, + FILE + }; + class LOGGER { + public: + LOGGER(LOGGER_TYPE type, std::string prefix); + LOGGER(LOGGER_TYPE type, std::string filename, std::string prefix); + bool log(std::string msg); + private: + LOGGER_TYPE type; + std::string filename; + std::string prefix; + std::ofstream logfile; + std::vector filebffr; + }; +} // BESKAR + +#endif //ETACG_LOGGER_H diff --git a/src/main.cpp b/src/main.cpp index 739a077..b631e83 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,15 +1,19 @@ #include "raylib.h" +#include "Logger/LOGGER.h" int main() { - InitWindow(800, 600, "Beskar Projekt"); - + BESKAR::LOGGER logger(BESKAR::LOGGER_TYPE::TERMINAL, "INIT"); + logger.log("Entered main()"); + logger.log("START Window Init"); + InitWindow(800, 600, "Escape The ACG"); + logger.log("Windows Initialised"); while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(BLACK); - DrawText("Beskar ist bereit!", 10, 10, 20, RAYWHITE); + DrawText("ETACG ist bereit!", 10, 10, 20, RAYWHITE); EndDrawing(); } CloseWindow(); return 0; -} \ No newline at end of file +}