summaryrefslogtreecommitdiff
path: root/desktop/source/pkgchk
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-10-25 21:09:01 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-10-26 10:22:36 +0200
commite4583f1ce81fc76dbfe55bcfd86d63ffe3518e5b (patch)
treefc86401a3dc3306aff276d91976edd066c4bf0e2 /desktop/source/pkgchk
parente8d130e7c6b2ff2a941372f386ee46fe8a95f218 (diff)
Introduce SimpleTextFormatter and format unopkg output using it
This will write log messages as plain text (no timestamp and other stuff like PlainTextFormatter). Warnings and errors will be prefixed accordingly. Change-Id: Id82512d7dd3907a4c7cd69a963a375966189dc20 Reviewed-on: https://gerrit.libreoffice.org/62370 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'desktop/source/pkgchk')
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_app.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index ab812f48f269..22d6f66d0255 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/logging/ConsoleHandler.hpp>
#include <com/sun/star/logging/FileHandler.hpp>
#include <com/sun/star/logging/LogLevel.hpp>
+#include <com/sun/star/logging/SimpleTextFormatter.hpp>
#include <com/sun/star/logging/XLogger.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
@@ -300,16 +301,24 @@ extern "C" int unopkg_main()
xComponentContext = getUNO(
option_verbose, option_shared, subcmd_gui, xLocalComponentContext );
+ // Initialize logging. This will log errors to the console and
+ // also to file if the --log-file parameter was provided.
logger.reset(new comphelper::EventLogger(xComponentContext, "unopkg"));
const Reference<XLogger> xLogger(logger->getLogger());
xLogger->setLevel(LogLevel::WARNING);
- xConsoleHandler.set(css::logging::ConsoleHandler::create(xComponentContext));
+ Reference<XLogFormatter> xLogFormatter(SimpleTextFormatter::create(xComponentContext));
+ Sequence < beans::NamedValue > aSeq { { "Formatter", Any(xLogFormatter) } };
+
+ xConsoleHandler.set(ConsoleHandler::createWithSettings(xComponentContext, aSeq));
xLogger->addLogHandler(xConsoleHandler);
xConsoleHandler->setLevel(LogLevel::WARNING);
xLogger->setLevel(LogLevel::WARNING);
+
+
if (!logFile.isEmpty())
{
- xFileHandler.set(css::logging::FileHandler::create(xComponentContext, logFile));
+ Sequence < beans::NamedValue > aSeq2 { { "Formatter", Any(xLogFormatter) }, {"FileURL", Any(logFile)} };
+ xFileHandler.set(css::logging::FileHandler::createWithSettings(xComponentContext, aSeq2));
xFileHandler->setLevel(LogLevel::WARNING);
xLogger->addLogHandler(xFileHandler);
}