aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-11-03 21:47:39 +0100
committerStefan Boberg <[email protected]>2021-11-03 21:47:39 +0100
commitc36fbb3c1582387eb64d3caaa7acf359663171d1 (patch)
tree687dff259a10ab500f1f2560b35f297e7ffc61fb
parentAdd /vsxmake* to .gitignore (diff)
downloadzen-c36fbb3c1582387eb64d3caaa7acf359663171d1.tar.xz
zen-c36fbb3c1582387eb64d3caaa7acf359663171d1.zip
log: improved log pattern for file log to make it easier to consume file logs from servers
-rw-r--r--zenserver/diag/logging.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/zenserver/diag/logging.cpp b/zenserver/diag/logging.cpp
index 74c5c2101..728001202 100644
--- a/zenserver/diag/logging.cpp
+++ b/zenserver/diag/logging.cpp
@@ -16,7 +16,10 @@ ZEN_THIRD_PARTY_INCLUDES_START
#include <spdlog/sinks/stdout_color_sinks.h>
ZEN_THIRD_PARTY_INCLUDES_END
+#include <zencore/filesystem.h>
#include <zencore/string.h>
+
+#include <chrono>
#include <memory>
// Custom logging -- test code, this should be tweaked
@@ -236,7 +239,7 @@ InitializeLogging(const ZenServerOptions& GlobalOptions)
/* truncate */ false,
uint16_t(/* max files */ 14));
#else
- auto FileSink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(zen::WideToUtf8(LogPath.c_str()),
+ auto FileSink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(zen::ToUtf8(LogPath),
/* max size */ 128 * 1024 * 1024,
/* max files */ 16,
/* rotate on open */ true);
@@ -288,6 +291,10 @@ InitializeLogging(const ZenServerOptions& GlobalOptions)
spdlog::flush_on(spdlog::level::err);
spdlog::flush_every(std::chrono::seconds{2});
spdlog::set_formatter(std::make_unique<logging::full_formatter>(GlobalOptions.LogId, std::chrono::system_clock::now()));
+
+ FileSink->set_pattern("[%C-%m-%d.%e %T] [%n] [%l] %v");
+
+ spdlog::info("log starting at {:%FT%T%z}", std::chrono::system_clock::now());
}
void