From 8650a7520baec35765bc837d9313325e0c7631d3 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Wed, 21 Jul 2021 01:23:53 +0100 Subject: add log file support --- NorthstarDedicatedTest/logging.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'NorthstarDedicatedTest/logging.cpp') diff --git a/NorthstarDedicatedTest/logging.cpp b/NorthstarDedicatedTest/logging.cpp index dbfc292e..66f2de4c 100644 --- a/NorthstarDedicatedTest/logging.cpp +++ b/NorthstarDedicatedTest/logging.cpp @@ -1,11 +1,10 @@ #include "pch.h" #include "logging.h" #include "context.h" -#include "dedicated.h" #include "sourceconsole.h" -#include -#include -#include +#include "spdlog/sinks/basic_file_sink.h" +#include +#include void InitialiseLogging() { @@ -13,4 +12,13 @@ void InitialiseLogging() freopen("CONOUT$", "w", stdout); spdlog::default_logger()->set_pattern("[%H:%M:%S] [%l] %v"); + spdlog::flush_on(spdlog::level::info); + + // generate log file, format should be nslog%d-%m-%Y %H-%M-%S.txt in gamedir/R2Northstar/logs + time_t time = std::time(nullptr); + tm currentTime = *std::localtime(&time); + std::stringstream stream; + stream << std::put_time(¤tTime, "R2Northstar/logs/nslog%d-%m-%Y %H-%M-%S.txt"); + + spdlog::default_logger()->sinks().push_back(std::make_shared(stream.str(), false)); } \ No newline at end of file -- cgit v1.2.3