aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/logging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/logging.cpp')
-rw-r--r--NorthstarDedicatedTest/logging.cpp16
1 files changed, 12 insertions, 4 deletions
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 <vector>
-#include <iostream>
-#include <chrono>
+#include "spdlog/sinks/basic_file_sink.h"
+#include <iomanip>
+#include <sstream>
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(&currentTime, "R2Northstar/logs/nslog%d-%m-%Y %H-%M-%S.txt");
+
+ spdlog::default_logger()->sinks().push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(stream.str(), false));
} \ No newline at end of file