#14446 Initialize loggers before reading cloud config files

Cloud services are configured from RiaApplication::initialize(), which runs before the subclasses append their logger instances. All messages from the cloud config file search were therefore dropped. Add a virtual initializeLoggers() called before the cloud configuration is read, and move creation of the file logger and the std out logger into the overrides. The message panel logger depends on the main windows, and is still created in RiaGuiApplication::initialize().

Do not write fields with IO disabled to the application store, mirroring the check already present when reading. This stops the cloud service configuration from being persisted into the user preferences file.
This commit is contained in:
Magne Sjaastad
2026-08-04 13:05:03 +02:00
parent 1aa95936fc
commit 5efcf88949
7 changed files with 39 additions and 12 deletions
@@ -1697,6 +1697,13 @@ void RiaApplication::initialize()
m_preferences->initAfterReadRecursively();
applyPreferences();
// Parse log level early so it's available when the loggers are created
parseLogLevelFromQtArguments();
// Create loggers before reading the cloud configuration, to make sure the messages from the config file search
// are reported
initializeLoggers();
RiaConnectorTools::configureCloudServices();
// Start with a project
@@ -1710,9 +1717,6 @@ void RiaApplication::initialize()
RiaCafLoggingManager::initializeCafLogging();
initializeDataLoadController();
// Parse log level early so it's available before logger is created in subclass initialize()
parseLogLevelFromQtArguments();
}
//--------------------------------------------------------------------------------------------------
@@ -233,6 +233,10 @@ protected:
static std::vector<caf::PdmDeprecation> defaultDeprecations();
protected:
// Create the logger instances required to report messages during application startup. Called from initialize()
// before any startup configuration is read, to make sure messages from the startup sequence are logged.
virtual void initializeLoggers() {}
void initializeDataLoadController();
void parseLogLevelFromQtArguments();
@@ -109,6 +109,14 @@ void RiaConsoleApplication::initialize()
RiaApplication::initialize();
m_socketServer = new RiaSocketServer( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaConsoleApplication::initializeLoggers()
{
auto logger = std::make_unique<RiaStdOutLogger>();
// Use command line log level if provided, otherwise use preference-based level
@@ -122,8 +130,6 @@ void RiaConsoleApplication::initialize()
}
RiaLogging::appendLoggerInstance( std::move( logger ) );
m_socketServer = new RiaSocketServer( this );
}
//--------------------------------------------------------------------------------------------------
@@ -46,6 +46,7 @@ public:
protected:
// Protected implementation specific overrides
void initializeLoggers() override;
void invokeProcessEvents( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) override;
void onProjectOpeningError( const QString& errMsg ) override;
void onProjectOpened() override;
@@ -551,16 +551,23 @@ void RiaGuiApplication::initialize()
RiaLogging::appendLoggerInstance( std::move( logger ) );
}
{
auto logFolder = QDir::homePath() + "/.resinsight/logs";
auto fileLogger = std::make_unique<RiaFileLogger>( logFolder.toStdString() );
fileLogger->setLevel( int( RiaLogging::logLevelBasedOnPreferences() ) );
RiaLogging::appendLoggerInstance( std::move( fileLogger ) );
}
m_socketServer = new RiaSocketServer( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGuiApplication::initializeLoggers()
{
// The message panel logger requires the main windows, and is created in initialize(). The file logger has no
// such dependency, and is created here to capture messages from the early startup sequence.
auto logFolder = QDir::homePath() + "/.resinsight/logs";
auto fileLogger = std::make_unique<RiaFileLogger>( logFolder.toStdString() );
fileLogger->setLevel( int( RiaLogging::logLevelBasedOnPreferences() ) );
RiaLogging::appendLoggerInstance( std::move( fileLogger ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -126,6 +126,8 @@ public:
void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) override;
protected:
void initializeLoggers() override;
bool notify( QObject* receiver, QEvent* event ) override;
// use the checkWithUserBeforeClose function, to get all checks in one go
@@ -131,6 +131,9 @@ void PdmSettings::writeFieldsToApplicationStore( const caf::PdmObjectHandle* obj
if ( children.empty() )
{
// Do not write value if field is not writable
if ( fieldHandle->xmlCapability() && !fieldHandle->xmlCapability()->isIOWritable() ) continue;
if ( caf::PdmValueField* valueField = dynamic_cast<caf::PdmValueField*>( fieldHandle ) )
{
settings.setValue( context + fieldHandle->keyword(), valueField->toQVariant() );