Skip to content

Commit

Permalink
ECS: Fix logger compil
Browse files Browse the repository at this point in the history
PATCH
  • Loading branch information
Saverio976 committed Oct 4, 2023
1 parent 804e958 commit 285dba2
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
45 changes: 41 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
branches: [main, dev]

env:
BRANCH: "main"
BRANCH: "feature/RB-61-basic-missiles"
RAYLIB_TAG: "4.5.0"
DATE_TAG: "v3.0.1"

jobs:
release-create:
Expand Down Expand Up @@ -37,7 +38,7 @@ jobs:
release-windows:
runs-on: windows-latest
needs: [release-create, raylib-to-tar]
needs: [release-create, raylib-to-tar, date-to-tar]

steps:
- name: Checkout
Expand Down Expand Up @@ -78,7 +79,7 @@ jobs:

release-linux:
runs-on: ubuntu-latest
needs: [release-create, raylib-to-tar]
needs: [release-create, raylib-to-tar, date-to-tar]

steps:
- name: Checkout
Expand Down Expand Up @@ -114,7 +115,7 @@ jobs:

release-macos:
runs-on: macos-latest
needs: [release-create, raylib-to-tar]
needs: [release-create, raylib-to-tar, date-to-tar]

steps:
- name: Checkout
Expand Down Expand Up @@ -183,3 +184,39 @@ jobs:
with:
name: raylib.tar
path: ./raylib.tar

date-to-tar:
runs-on: ubuntu-latest
needs: release-create

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install deps
run: sudo apt-get update && sudo apt-get install -y tar git

- name: Get Date
run: |
git clone https://github.com/HowardHinnant/date.git date-repo
cd date-repo || exit 14
git checkout ${{ env.DATE_TAG }}
cd ..
- name: To Tar
run: |
tar -cvf date.tar date-repo
- name: Upload To Release
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ needs.release-create.outputs.release }} ./date.tar
- name: Upload To Artifact
if: github.ref != 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: date.tar
path: ./date.tar
1 change: 1 addition & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ cmake_minimum_required(VERSION 3.15)

add_subdirectory(raylib)
add_subdirectory(boost)
add_subdirectory(date)
24 changes: 24 additions & 0 deletions deps/date/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.15)

include(FetchContent)

FetchContent_Declare(
date
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_CONFIGURATION_TYPES=\"Release;Release\"" "-DCONFIG=Release"
URL "https://github.com/X-R-G-B/R-Bus/releases/latest/download/date.tar"
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)

FetchContent_MakeAvailable(date)

target_include_directories(
${PROJECT_NAME_CLIENT}
PRIVATE
${date_SOURCE_DIR}/include
)

target_include_directories(
${PROJECT_NAME_SERVER}
PRIVATE
${date_SOURCE_DIR}/include
)
13 changes: 8 additions & 5 deletions src/ECS/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <format>
#include <iostream>
#include "Registry.hpp"
#include "date/date.h"
#include <sstream>
#include <string>

namespace Logger {
void fatal(const std::string &message)
Expand Down Expand Up @@ -135,13 +138,13 @@ namespace Logger {
};
#endif

auto const now = std::chrono::get_tzdb().current_zone()->to_local(
std::chrono::system_clock::now());
std::string mes;
auto const now = std::chrono::system_clock::now();
auto it = _callbacks.find(levelT);
std::stringstream s;
std::string mes;

mes = std::format("{:%Y-%m-%d %H:%M:%S}", now) + " [" + level + "] "
+ message;
s << now << " [" << level << "] " << message;
mes = s.str();
std::cerr << colors[levelT] << mes << colors[LogLevel::MAXLOGLEVEL]
<< std::endl;
if (it != _callbacks.end()) {
Expand Down

0 comments on commit 285dba2

Please sign in to comment.