From e21ece71a70906526e2c3eceaac3bc0c93bb7831 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 26 Oct 2018 15:07:29 +0200 Subject: unopkg: Make logging to default location work again Change-Id: Ie0b476164b370f58e0b220cee56ed52896753ade Reviewed-on: https://gerrit.libreoffice.org/62394 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- desktop/source/deployment/manager/dp_manager.cxx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'desktop/source') diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 4a010a6ce6e6..d2c33e298199 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -76,6 +81,7 @@ using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::logging; namespace dp_log { extern comphelper::service_decl::ServiceDecl const serviceDecl; @@ -353,7 +359,7 @@ Reference PackageManagerImpl::create( that->m_activePackages = "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages"; that->m_registrationData = "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"; that->m_registryCache = "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/registry"; - logFile = "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/log.txt"; + logFile = "$UNO_USER_PACKAGES_CACHE/log.txt"; //We use the extension .sys for the file because on Windows Vista a sys //(as well as exe and dll) file //will not be written in the VirtualStore. For example if the process has no @@ -371,7 +377,7 @@ Reference PackageManagerImpl::create( that->m_activePackages = "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages"; that->m_registrationData = "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER"; that->m_registryCache = "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/registry"; - logFile = "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/log.txt"; + logFile = "$SHARED_EXTENSIONS_USER/log.txt"; #if !HAVE_FEATURE_READONLY_INSTALLSET // The "shared" extensions are read-only when we have a // read-only installset. @@ -382,7 +388,7 @@ Reference PackageManagerImpl::create( that->m_activePackages = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"; that->m_registrationData = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER"; that->m_registryCache = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/registry"; - logFile = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/log.txt"; + logFile = "$BUNDLED_EXTENSIONS_USER/log.txt"; //No stamp file. We assume that bundled is always readonly. It must not be //modified from ExtensionManager but only by the installer } @@ -414,6 +420,16 @@ Reference PackageManagerImpl::create( if (!that->m_readOnly && !logFile.isEmpty()) { + // Initialize logger which will be used in ProgressLogImpl (created below) + rtl::Bootstrap::expandMacros(logFile); + comphelper::EventLogger logger(xComponentContext, "unopkg"); + const Reference xLogger(logger.getLogger()); + Reference xLogFormatter(SimpleTextFormatter::create(xComponentContext)); + Sequence < beans::NamedValue > aSeq2 { { "Formatter", Any(xLogFormatter) }, {"FileURL", Any(logFile)} }; + Reference xFileHandler(css::logging::FileHandler::createWithSettings(xComponentContext, aSeq2)); + xFileHandler->setLevel(LogLevel::WARNING); + xLogger->addLogHandler(xFileHandler); + const Any any_logFile(logFile); that->m_xLogFile.set( that->m_xComponentContext->getServiceManager() -- cgit