aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-27 17:23:36 +0200
committerStefan Boberg <[email protected]>2021-08-27 17:23:36 +0200
commit69e8a4d0db35c372fafb06bee7ed5ce4ec1e34c5 (patch)
tree993ce428cc968a175ab998455987083bedb0fa10
parentRemoved FileCasImpl (unused) (diff)
downloadzen-69e8a4d0db35c372fafb06bee7ed5ce4ec1e34c5.tar.xz
zen-69e8a4d0db35c372fafb06bee7ed5ce4ec1e34c5.zip
Added basic file logging
-rw-r--r--zenserver/diag/logging.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/zenserver/diag/logging.cpp b/zenserver/diag/logging.cpp
index 2bf0e50aa..2583784c3 100644
--- a/zenserver/diag/logging.cpp
+++ b/zenserver/diag/logging.cpp
@@ -4,8 +4,10 @@
#include "config.h"
+#include <zencore/string.h>
#include <spdlog/pattern_formatter.h>
#include <spdlog/sinks/ansicolor_sink.h>
+#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
#include <memory>
@@ -186,9 +188,16 @@ InitializeLogging(const ZenServerOptions& GlobalOptions)
{
EnableVTMode();
+ std::filesystem::path LogPath = GlobalOptions.DataDir / "logs/zenserver.txt";
+
+ auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(zen::WideToUtf8(LogPath.c_str()), /* truncate */ true);
+ file_sink->set_level(spdlog::level::trace);
+
auto& sinks = spdlog::default_logger()->sinks();
sinks.clear();
sinks.push_back(std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
+ sinks.push_back(file_sink);
+
spdlog::set_level(spdlog::level::debug);
spdlog::set_formatter(std::make_unique<logging::full_formatter>(GlobalOptions.LogId, std::chrono::system_clock::now()));
}