This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch improve_qt_wchar_support in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit bfcc7b9bbd699a95a10798b39ee805e274177a4a Author: Stephen Webb <[email protected]> AuthorDate: Tue Dec 23 11:46:37 2025 +1100 Ensure a Qt fatal message is flushed when using buffered/async output --- src/main/cpp-qt/messagehandler.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/cpp-qt/messagehandler.cpp b/src/main/cpp-qt/messagehandler.cpp index 67580935..4f858b5c 100644 --- a/src/main/cpp-qt/messagehandler.cpp +++ b/src/main/cpp-qt/messagehandler.cpp @@ -15,7 +15,9 @@ * limitations under the License. */ #include <log4cxx-qt/messagehandler.h> +#include <log4cxx-qt/transcoder.h> #include <log4cxx/logger.h> +#include <log4cxx/logmanager.h> #include <log4cxx/spi/location/locationinfo.h> namespace LOG4CXX_NS { @@ -23,34 +25,37 @@ namespace qt { void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message ) { - LOG4CXX_NS::LoggerPtr qtLogger = LOG4CXX_NS::Logger::getLogger( context.category ); - LOG4CXX_NS::spi::LocationInfo location( context.file, - LOG4CXX_NS::spi::LocationInfo::calcShortFileName(context.file), - context.function, - context.line ); - + spi::LocationInfo location + ( context.file + , spi::LocationInfo::calcShortFileName(context.file) + , context.function + , context.line + ); + LOG4CXX_DECODE_QSTRING(lsMsg, message); + auto qtLogger = Logger::getLogger( context.category ); switch ( type ) { case QtMsgType::QtDebugMsg: - qtLogger->debug( message.toStdString(), location ); + qtLogger->debug(lsMsg, location); break; case QtMsgType::QtWarningMsg: - qtLogger->warn( message.toStdString(), location ); + qtLogger->warn(lsMsg, location); break; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtMsgType::QtInfoMsg: - qtLogger->info( message.toStdString(), location ); + qtLogger->info(lsMsg, location); break; #endif case QtMsgType::QtCriticalMsg: - qtLogger->error( message.toStdString(), location ); + qtLogger->error(lsMsg, location); break; case QtMsgType::QtFatalMsg: - qtLogger->fatal( message.toStdString(), location ); + qtLogger->fatal(lsMsg, location); + LogManager::shutdown(); std::abort(); } }
