@@ -432,6 +432,9 @@ APP_EXPORT
432432#endif
433433int main ( int argc, char *argv[] )
434434{
435+ // log messages written before creating QgsApplication
436+ QStringList preApplicationLogMessages;
437+
435438#ifdef Q_OS_MACX
436439 // Increase file resource limits (i.e., number of allowed open files)
437440 // (from code provided by Larry Biehl, Purdue University, USA, from 'MultiSpec' project)
@@ -868,11 +871,11 @@ int main( int argc, char *argv[] )
868871 {
869872 if ( !QgsSettings::setGlobalSettingsPath ( globalsettingsfile ) )
870873 {
871- QgsMessageLog::logMessage ( QObject::tr ( " Invalid globalsettingsfile path: %1" ).arg ( globalsettingsfile ), QStringLiteral ( " QGIS" ) );
874+ preApplicationLogMessages << QObject::tr ( " Invalid globalsettingsfile path: %1" ).arg ( globalsettingsfile ), QStringLiteral ( " QGIS" );
872875 }
873876 else
874877 {
875- QgsMessageLog::logMessage ( QObject::tr ( " Successfully loaded globalsettingsfile path: %1" ).arg ( globalsettingsfile ), QStringLiteral ( " QGIS" ) );
878+ preApplicationLogMessages << QObject::tr ( " Successfully loaded globalsettingsfile path: %1" ).arg ( globalsettingsfile ), QStringLiteral ( " QGIS" );
876879 }
877880 }
878881
@@ -972,6 +975,10 @@ int main( int argc, char *argv[] )
972975
973976 QgsApplication myApp ( argc, argv, myUseGuiFlag );
974977
978+ // write the log messages written before creating QgsApplication
979+ for ( const QString &preApplicationLogMessage : qgis::as_const ( preApplicationLogMessages ) )
980+ QgsMessageLog::logMessage ( preApplicationLogMessage );
981+
975982 // Settings migration is only supported on the default profile for now.
976983 if ( profileName == QLatin1String ( " default" ) )
977984 {
0 commit comments