diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-21 01:23:53 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-21 01:23:53 +0100 |
commit | 8650a7520baec35765bc837d9313325e0c7631d3 (patch) | |
tree | e6c6f8051c5d22b0233a7ea7f7da9888229d4085 /NorthstarDedicatedTest | |
parent | 93fe64e04ed766727634e5b5f6906f6461a70711 (diff) | |
download | NorthstarLauncher-8650a7520baec35765bc837d9313325e0c7631d3.tar.gz NorthstarLauncher-8650a7520baec35765bc837d9313325e0c7631d3.zip |
add log file support
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/logging.cpp | 16 | ||||
-rw-r--r-- | NorthstarDedicatedTest/squirrel.h | 4 |
2 files changed, 14 insertions, 6 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(¤tTime, "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 diff --git a/NorthstarDedicatedTest/squirrel.h b/NorthstarDedicatedTest/squirrel.h index 3c8f9fed..bb377604 100644 --- a/NorthstarDedicatedTest/squirrel.h +++ b/NorthstarDedicatedTest/squirrel.h @@ -52,8 +52,7 @@ public: public: SquirrelManager() : sqvm(nullptr) - { - } + {} void ExecuteCode(const char* code) { @@ -96,6 +95,7 @@ public: } } } + void AddFuncRegistration(std::string returnType, std::string name, std::string argTypes, std::string helpText, SQFunction func) { |