[Libreoffice-commits] core.git: extensions/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 21 13:28:08 UTC 2020
extensions/source/logging/consolehandler.cxx | 39 ++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
New commits:
commit 015e9f780bc133788f79868bb7fb0b1d4e81f5f3
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Fri Jan 10 07:12:28 2020 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Jan 21 14:27:35 2020 +0100
unopkg: Correctly display log messages on Windows
Change-Id: I5ec8c55f9afac8d6f7f697c0e5e387e88db4fde7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86517
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/extensions/source/logging/consolehandler.cxx b/extensions/source/logging/consolehandler.cxx
index d1455baa3178..d213f5aab002 100644
--- a/extensions/source/logging/consolehandler.cxx
+++ b/extensions/source/logging/consolehandler.cxx
@@ -31,9 +31,15 @@
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <osl/thread.hxx>
#include <stdio.h>
+#ifdef _WIN32
+#include <prewin.h>
+#include <postwin.h>
+#endif
+
namespace logging
{
using ::com::sun::star::logging::XConsoleHandler;
@@ -215,10 +221,38 @@ namespace logging
void SAL_CALL ConsoleHandler::flush( )
{
MethodGuard aGuard( *this );
+#ifndef _WIN32
fflush( stdout );
fflush( stderr );
+#endif
+ }
+
+ namespace
+ {
+ void lcl_printConsole(const OString& sText)
+ {
+#ifdef _WIN32
+ DWORD nWrittenChars = 0;
+ OUString s = OStringToOUString(sText, RTL_TEXTENCODING_ASCII_US);
+ WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), s.getStr(), s.getLength() * 2,
+ &nWrittenChars, nullptr);
+#else
+ fprintf(stdout, "%s\n", sText.getStr());
+#endif
}
+ void lcl_printConsoleError(const OString& sText)
+ {
+#ifdef _WIN32
+ DWORD nWrittenChars = 0;
+ OUString s = OStringToOUString(sText, RTL_TEXTENCODING_ASCII_US);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), s.getStr(), s.getLength() * 2,
+ &nWrittenChars, nullptr);
+#else
+ fprintf(stderr, "%s\n", sText.getStr());
+#endif
+ }
+ } // namespace
sal_Bool SAL_CALL ConsoleHandler::publish( const LogRecord& _rRecord )
{
@@ -229,10 +263,9 @@ namespace logging
return false;
if ( _rRecord.Level >= m_nThreshold )
- fprintf( stderr, "%s\n", sEntry.getStr() );
+ lcl_printConsoleError(sEntry);
else
- fprintf( stdout, "%s\n", sEntry.getStr() );
-
+ lcl_printConsole(sEntry);
return true;
}
More information about the Libreoffice-commits
mailing list