mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add option to Preferences to flush file loggers when a signal is triggered
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaMainTools.h"
|
||||
#include "RiaFileLogger.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaRegressionTestRunner.h"
|
||||
#include "RiaSocketCommand.h"
|
||||
|
||||
@@ -25,6 +27,32 @@
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void manageSegFailure( int signalCode )
|
||||
{
|
||||
// Executing function here is not safe, but works as expected on Windows. Behavior on Linux is undefined, but will
|
||||
// work in some cases.
|
||||
// https://github.com/gabime/spdlog/issues/1607
|
||||
|
||||
auto loggers = RiaLogging::loggerInstances();
|
||||
|
||||
QString str = QString( "Segmentation fault. Signal code: %1" ).arg( signalCode );
|
||||
|
||||
for ( auto logger : loggers )
|
||||
{
|
||||
if ( auto fileLogger = dynamic_cast<RiaFileLogger*>( logger ) )
|
||||
{
|
||||
fileLogger->error( str.toStdString().data() );
|
||||
|
||||
fileLogger->flush();
|
||||
}
|
||||
}
|
||||
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user