aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/logging.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-07-21 01:23:53 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-07-21 01:23:53 +0100
commit8650a7520baec35765bc837d9313325e0c7631d3 (patch)
treee6c6f8051c5d22b0233a7ea7f7da9888229d4085 /NorthstarDedicatedTest/logging.cpp
parent93fe64e04ed766727634e5b5f6906f6461a70711 (diff)
downloadNorthstarLauncher-8650a7520baec35765bc837d9313325e0c7631d3.tar.gz
NorthstarLauncher-8650a7520baec35765bc837d9313325e0c7631d3.zip
add log file support
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