Add option to Preferences to flush file loggers when a signal is triggered

This commit is contained in:
Magne Sjaastad
2024-01-31 14:41:57 +01:00
parent 710b91d161
commit 06766b3650
6 changed files with 75 additions and 0 deletions

View File

@@ -137,6 +137,7 @@ RiaPreferences::RiaPreferences()
m_loggerFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxAndTextEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_loggerFlushInterval, "loggerFlushInterval", 500, "Logging Flush Interval [ms]" );
CAF_PDM_InitField( &m_loggerTrapSignalAndFlush, "loggerTrapSignalAndFlush", false, "Trap SIGNAL and Flush File Logs" );
CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address" );
ssihubAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
@@ -478,6 +479,8 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging" );
loggingGroup->add( &m_loggerFilename );
loggingGroup->add( &m_loggerFlushInterval );
loggingGroup->add( &m_loggerTrapSignalAndFlush );
m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
}
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
@@ -971,6 +974,14 @@ int RiaPreferences::loggerFlushInterval() const
return m_loggerFlushInterval();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferences::loggerTrapSignalAndFlush() const
{
return m_loggerTrapSignalAndFlush();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -119,6 +119,7 @@ public:
QString loggerFilename() const;
int loggerFlushInterval() const;
bool loggerTrapSignalAndFlush() const;
RiaPreferencesGeoMech* geoMechPreferences() const;
RiaPreferencesSummary* summaryPreferences() const;
@@ -209,6 +210,7 @@ private:
// Logging
caf::PdmField<std::pair<bool, QString>> m_loggerFilename;
caf::PdmField<int> m_loggerFlushInterval;
caf::PdmField<bool> m_loggerTrapSignalAndFlush;
// Surface Import
caf::PdmField<double> m_surfaceImportResamplingDistance;

View File

@@ -83,6 +83,14 @@ public:
if ( m_spdlogger ) m_spdlogger->warn( message );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void flush()
{
if ( m_spdlogger ) m_spdlogger->flush();
}
private:
std::shared_ptr<spdlog::logger> m_spdlogger;
};
@@ -150,3 +158,11 @@ void RiaFileLogger::debug( const char* message )
{
m_impl->debug( message );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaFileLogger::flush()
{
if ( m_impl ) m_impl->flush();
}

View File

@@ -37,6 +37,8 @@ public:
void info( const char* message ) override;
void debug( const char* message ) override;
void flush();
private:
int m_logLevel;