Skip to content

Commit

Permalink
Merge pull request #459 from GrognardsFromHell/logflush
Browse files Browse the repository at this point in the history
Flush the log-file to avoid truncated lines when the game crashes
  • Loading branch information
DudeMcDude authored Jan 19, 2021
2 parents f033cd7 + 7e62f60 commit 979f9d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: nuget/setup-nuget@v1
- name: Download and Extract Dependencies
run: |
curl -L -o dependencies.7z https://github.com/GrognardsFromHell/Dependencies/releases/download/v1.6/dependencies.7z
curl -L -o dependencies.7z https://github.com/GrognardsFromHell/Dependencies/releases/download/v1.7/dependencies.7z
7z x dependencies.7z
- name: Install NuGet packages
run: |
Expand Down
2 changes: 2 additions & 0 deletions Infrastructure/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ void InitLogging(const std::wstring &logFile)
// Always log to a file
DeleteFile(logFile.c_str());
auto fileSink = std::make_shared<spdlog::sinks::simple_file_sink_mt>(ucs2_to_local(logFile), true);
// This is slower but prevents logs from being truncated on crash
fileSink->set_force_flush(true);
auto debugSink = std::make_shared<spdlog::sinks::msvc_sink_mt>();
spdlog::drop_all(); // Reset all previous loggers
logger = spdlog::create("core", {fileSink, debugSink});
Expand Down

0 comments on commit 979f9d3

Please sign in to comment.