summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-03-22 17:10:51 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-03-25 15:45:37 +0100
commit9fb2fa9bddef863c1e444861f939d4d7956dcc4b (patch)
tree059f551769ddddeac996a462f0a349ec81b4ed15
parentd96f1f068a46187e3138e74933fa412e52ef0e55 (diff)
Best effort to create directories of SAL_LOG_FILE
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165272 Tested-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> (cherry picked from commit 1339c42c4aea269e5265277647361ae91882d8a5) Conflicts: sal/Library_sal.mk sal/osl/all/log.cxx Change-Id: Ia86ac0e022579d155e92de3b853d57860b5b97e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165192 Tested-by: allotropia jenkins <jenkins@allotropia.de> Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
-rw-r--r--sal/Library_sal.mk1
-rw-r--r--sal/osl/all/log.cxx7
2 files changed, 8 insertions, 0 deletions
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index e84ed0aaf1b5..53b35dc8342b 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_libs,sal,\
$(if $(filter LINUX,$(OS)), \
-ldl \
-lrt \
+ -lstdc++fs \
) \
$(if $(filter SOLARIS,$(OS)), \
-lnsl \
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 84f88f259daa..3377d615a6ab 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -19,9 +19,13 @@
#include <stdio.h>
#include <string.h>
+#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
+#include <experimental/filesystem>
#include <fstream>
+#include <system_error>
#include <config_global.h>
+#include <o3tl/temporary.hxx>
#include <osl/thread.hxx>
#include <rtl/string.h>
#include <sal/detail/log.h>
@@ -201,6 +205,9 @@ std::ofstream * getLogFile() {
if (logFile)
{
+ std::experimental::filesystem::create_directories(
+ std::experimental::filesystem::path(logFile).remove_filename(),
+ o3tl::temporary(std::error_code()));
// stays until process exits
static std::ofstream file(logFile, std::ios::app | std::ios::out);
pResult = &file;