From 8e9579055f6efea343bbc1ca7c1422b99be63257 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 9 Apr 2023 14:42:57 +0300 Subject: [PATCH] logger: create logdir if non-existent --- lib/utils/mu-logger.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/utils/mu-logger.cc b/lib/utils/mu-logger.cc index 882f3ba5..632b7cdb 100644 --- a/lib/utils/mu-logger.cc +++ b/lib/utils/mu-logger.cc @@ -49,6 +49,13 @@ maybe_open_logfile() if (MuStream.is_open()) return true; + const auto logdir{to_string_gchar(g_path_get_dirname(MuLogPath.c_str()))}; + if (g_mkdir_with_parents(logdir.c_str(), 0700) != 0) { + std::cerr << "creating " << logdir << " failed:" << g_strerror(errno) + << std::endl; + return false; + } + MuStream.open(MuLogPath, std::ios::out | std::ios::app); if (!MuStream.is_open()) { std::cerr << "opening " << MuLogPath << " failed:" << g_strerror(errno)