Selaa lähdekoodia

Fix logging

Ensure log directory base path is relative to the executable.
master
TheoryOfNekomata 1 vuosi sitten
vanhempi
commit
9be297df6f
8 muutettua tiedostoa jossa 41 lisäystä ja 23 poistoa
  1. +2
    -2
      00-build-cache-debug-x64
  2. +15
    -0
      01-build-executable
  3. +0
    -3
      01-build-game
  4. +0
    -3
      02-build-server
  5. +7
    -0
      03-run-tests
  6. +10
    -10
      CMakeLists.txt
  7. +6
    -5
      src/packages/log/IZ_log.c
  8. +1
    -0
      src/packages/log/IZ_log.h

+ 2
- 2
00-build-cache-debug-x64 Näytä tiedosto

@@ -2,10 +2,10 @@

cmake \
-DCMAKE_SIZEOF_VOID_P=8 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_MAKE_PROGRAM=ninja \
-DCMAKE_C_COMPILER=cc \
-DCMAKE_C_FLAGS=-m64 \
-G Ninja \
-S . \
-B ./build/Debug
-B ./build/$BUILD_TYPE

+ 15
- 0
01-build-executable Näytä tiedosto

@@ -0,0 +1,15 @@
#!/usr/bin/env sh

if [ "$BUILD_TYPE" = "" ]
then
echo "No build type specified. Try Debug or Release."
exit
fi

if [ "$EXECUTABLE" = "" ]
then
echo "No executable specified. Refer to CMakeLists.txt for available executables to build."
exit
fi

cmake --build "./build/$BUILD_TYPE" -t "$EXECUTABLE"

+ 0
- 3
01-build-game Näytä tiedosto

@@ -1,3 +0,0 @@
#!/usr/bin/env sh

cmake --build build/Debug -t game

+ 0
- 3
02-build-server Näytä tiedosto

@@ -1,3 +0,0 @@
#!/usr/bin/env sh

cmake --build build/Debug -t server

+ 7
- 0
03-run-tests Näytä tiedosto

@@ -0,0 +1,7 @@
#!/usr/bin/env sh

if [ "$BUILD_TYPE" = "" ]
then
return 1
fi
cmake --build "./build/$BUILD_TYPE" -t server

+ 10
- 10
CMakeLists.txt Näytä tiedosto

@@ -217,7 +217,7 @@ target_link_libraries(
)

add_executable(
game-test-geometry
test-game-geometry
subprojects/bdd-for-c/bdd-for-c.h
subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h

@@ -229,7 +229,7 @@ add_executable(
)

add_executable(
game-test-input
test-game-input
subprojects/bdd-for-c/bdd-for-c.h
subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h

@@ -265,13 +265,13 @@ add_executable(
)

target_link_libraries(
game-test-input
test-game-input
SDL2main
SDL2
)

add_executable(
game-test-output
test-game-output
subprojects/bdd-for-c/bdd-for-c.h
subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h

@@ -286,7 +286,7 @@ add_executable(
)

add_executable(
game-test-memory
test-game-memory
subprojects/bdd-for-c/bdd-for-c.h
subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h

@@ -310,13 +310,13 @@ add_executable(
)

target_link_libraries(
game-test-memory
test-game-memory
SDL2main
SDL2
)

add_executable(
game-test-data
test-game-data
subprojects/bdd-for-c/bdd-for-c.h
subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h

@@ -329,7 +329,7 @@ add_executable(
)

target_link_libraries(
game-test-data
test-game-data
SDL2main
SDL2
)
@@ -443,10 +443,10 @@ if (IZ_PLATFORM STREQUAL "WINDOWS")
"${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libcrypto-1_1-${IZ_SDL_ARCH}.dll"
$<TARGET_FILE_DIR:server>)

add_custom_command(TARGET game-test-input POST_BUILD
add_custom_command(TARGET test-game-input POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.dll"
$<TARGET_FILE_DIR:game-test-input>)
$<TARGET_FILE_DIR:test-game-input>)
endif ()

add_custom_command(TARGET game POST_BUILD


+ 6
- 5
src/packages/log/IZ_log.c Näytä tiedosto

@@ -48,16 +48,17 @@ void IZ_LogInitialize(const char* context, bool force_output) {
stderr_dest = stderr;
#else
const char* log_dir = "logs";
if (!IZ_isdir(log_dir)) {
IZ_mkdir(log_dir);
char base_log_dir[128];
sprintf(base_log_dir, "%s/%s", SDL_GetBasePath(), log_dir);
if (!IZ_isdir(base_log_dir)) {
IZ_mkdir(base_log_dir);
}
char stdout_filename[128] = "";
char stderr_filename[128] = "";
char* now = IZ_TimerNowPathSafe();

// fixme
sprintf(stdout_filename, "%s/%s-out-%s.log", log_dir, context, now);
sprintf(stderr_filename, "%s/%s-err-%s.log", log_dir, context, now);
sprintf(stdout_filename, "%s/%s-out-%s.log", base_log_dir, context, now);
sprintf(stderr_filename, "%s/%s-err-%s.log", base_log_dir, context, now);
IZ_fopen(&stdout_dest, stdout_filename, "a");
IZ_fopen(&stderr_dest, stderr_filename, "a");
#endif


+ 1
- 0
src/packages/log/IZ_log.h Näytä tiedosto

@@ -16,6 +16,7 @@
#define IZ_LOG_LEVEL_FLAG_WARN
#define IZ_LOG_LEVEL_FLAG_ERROR

#include <SDL_filesystem.h>
#if defined IZ_WINDOWS
#include <io.h>
#include <SDL_syswm.h>


Ladataan…
Peruuta
Tallenna