#13126 RiaLogging: Use std::string_view instead of QString for logging

This commit is contained in:
Kristian Bendiksen committed 2026-05-08 10:11:09 +02:00
1 parent 4957bf5a8b
commit 5ffcb69acc
231 files changed
+1082 -893

No files matched your search

@@ -38,6 +38,7 @@
#include "RiaPreferencesSumo.h"
#include "RiaPreferencesSystem.h"
#include "RiaProjectModifier.h"
#include "RiaQStringFormatter.h"
#include "RiaRegressionTestRunner.h"
#include "RiaSocketServer.h"
#include "RiaTextStringTools.h"
@@ -390,7 +391,7 @@ void RiaApplication::setThreadCount() const
if ( threadCount.has_value() )
{
RiaLogging::info( QString( "Setting number of threads to %1 from %2" ).arg( threadCount.value() ).arg( source ) );
RiaLogging::info( std::format( "Setting number of threads to {} from {}", threadCount.value(), source ) );
RiaOpenMPTools::setMaxThreads( threadCount.value() );
}
@@ -529,13 +530,13 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
onProjectBeingOpened();
RiaLogging::info( QString( "Starting to open project file : '%1'" ).arg( projectFileName ) );
RiaLogging::info( std::format( "Starting to open project file : '{}'", projectFileName ) );
// Create a absolute path file name, as this is required for update of file references in the project modifier object
QString fullPathProjectFileName = caf::Utils::absoluteFileName( projectFileName );
if ( !caf::Utils::fileExists( fullPathProjectFileName ) )
{
RiaLogging::info( QString( "File does not exist : '%1'" ).arg( fullPathProjectFileName ) );
RiaLogging::info( std::format( "File does not exist : '{}'", fullPathProjectFileName ) );
return false;
}
@@ -543,7 +544,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
std::vector<QString> deprecationMessages = m_project->readFile( defaultDeprecations() );
for ( const QString& deprecationMessage : deprecationMessages )
{
RiaLogging::info( deprecationMessage );
RiaLogging::info( deprecationMessage.toStdString() );
}
m_project->updatesAfterProjectFileIsRead();
@@ -909,7 +910,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
{
auto ensembleTask = progress.task( QString( "Loading Summary Ensemble '%1'" ).arg( ensemble->name() ), stepSize );
ensemble->loadDataAndUpdate();
RiaLogging::info( QString( "Loaded ensemble : '%1'" ).arg( ensemble->name() ) );
RiaLogging::info( std::format( "Loaded ensemble : '{}'", ensemble->name() ) );
}
sumMainCollection->updateEnsembleNames();
@@ -961,7 +962,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
else
{
RiaLogging::info( logText );
RiaLogging::info( logText.toStdString() );
}
return true;
@@ -1124,7 +1125,7 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
{
if ( gmcase->gridFileName() == fileName )
{
RiaLogging::warning( "File has already been opened. Cannot open the file twice! - " + fileName );
RiaLogging::warning( "File has already been opened. Cannot open the file twice! - " + fileName.toStdString() );
return false;
}
}
@@ -23,6 +23,7 @@
#include "RiaPreferences.h"
#include "RiaPreferencesGrid.h"
#include "RiaProjectModifier.h"
#include "RiaQStringFormatter.h"
#include "RiaSocketServer.h"
#include "RiaVersionInfo.h"
@@ -183,7 +184,7 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n
QString errMsg;
if ( !RiaApplication::generateCode( outputFile, &errMsg ) )
{
RiaLogging::error( QString( "Error: %1" ).arg( errMsg ) );
RiaLogging::error( std::format( "Error: {}", errMsg ) );
return RiaApplication::ApplicationStatus::EXIT_WITH_ERROR;
}
@@ -438,7 +439,7 @@ void RiaConsoleApplication::invokeProcessEvents( QEventLoop::ProcessEventsFlags
//--------------------------------------------------------------------------------------------------
void RiaConsoleApplication::onProjectOpeningError( const QString& errMsg )
{
RiaLogging::error( errMsg );
RiaLogging::error( errMsg.toStdString() );
}
//--------------------------------------------------------------------------------------------------
@@ -35,6 +35,7 @@
#include "RiaPreferencesGrid.h"
#include "RiaPreferencesSystem.h"
#include "RiaProjectModifier.h"
#include "RiaQStringFormatter.h"
#include "RiaRegressionTestRunner.h"
#include "RiaSocketServer.h"
#include "RiaVersionInfo.h"
@@ -581,7 +582,7 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n
QString errMsg;
if ( !RiaApplication::generateCode( outputFile, &errMsg ) )
{
RiaLogging::error( QString( "Error: %1" ).arg( errMsg ) );
RiaLogging::error( std::format( "Error: {}", errMsg ) );
return RiaApplication::ApplicationStatus::KEEP_GOING;
}
@@ -1105,12 +1105,12 @@ void RiaPreferences::importPreferenceValuesFromFile( const QString& fileName )
this->readObjectFromXmlString( fileContent, caf::PdmDefaultObjectFactory::instance() );
}
auto txt = "Imported preferences from " + fileName;
RiaLogging::info( txt );
RiaLogging::info( txt.toStdString() );
}
else
{
auto txt = QString( "Unable to open file: " ) + fileName;
RiaLogging::error( txt );
RiaLogging::error( txt.toStdString() );
}
}
@@ -1129,11 +1129,11 @@ void RiaPreferences::exportPreferenceValuesToFile( const QString& fileName )
file.close();
QString txt = "Exported preferences to " + fileName;
RiaLogging::info( txt );
RiaLogging::info( txt.toStdString() );
}
else
{
auto txt = QString( "Unable to open file: " ) + fileName;
RiaLogging::error( txt );
RiaLogging::error( txt.toStdString() );
}
}
@@ -310,13 +310,13 @@ void RiaPreferencesGrid::setGridModelReaderOverride( const std::string& readerNa
}
else
{
RiaLogging::warning( QString::fromStdString( "Unknown EGRID reader type specified on command line: " + readerName ) );
RiaLogging::warning( "Unknown EGRID reader type specified on command line: " + readerName );
return;
}
if ( readerType != RiaDefines::GridModelReader::NOT_SET )
{
RiaLogging::info( QString::fromStdString( "Using EGRID reader: " + readerName ) );
RiaLogging::info( "Using EGRID reader: " + readerName );
}
m_gridModelReaderOverride = readerType;
@@ -21,6 +21,7 @@
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaQStringFormatter.h"
#include "RiaVersionInfo.h"
#include "cafPdmUiTextEditor.h"
@@ -105,7 +106,7 @@ void RiaPreferencesOpenTelemetry::setData( const std::map<QString, QString>& key
}
else
{
RiaLogging::warning( QString( "Unknown OpenTelemetry config key: '%1'" ).arg( key ) );
RiaLogging::warning( std::format( "Unknown OpenTelemetry config key: '{}'", key ) );
}
}
}
@@ -8,6 +8,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaImageFileCompare.h
${CMAKE_CURRENT_LIST_DIR}/RiaImageTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaLogging.h
${CMAKE_CURRENT_LIST_DIR}/RiaQStringFormatter.h
${CMAKE_CURRENT_LIST_DIR}/RiaProjectModifier.h
${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTest.h
${CMAKE_CURRENT_LIST_DIR}/RiaImportEclipseCaseTools.h
@@ -22,6 +22,7 @@
#include "RiaConnectorTools.h"
#include "RiaLogging.h"
#include "RiaOAuthHttpServerReplyHandler.h"
#include "RiaQStringFormatter.h"
#include <QDateTime>
#include <QDesktopServices>
@@ -90,14 +91,14 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent,
if ( validOption )
{
RiaLogging::info( QString( "Setting SSL protocol to %1 (from RESINSIGHT_SSL_PROTOCOL)" ).arg( sslProtocolEnv ) );
RiaLogging::info( std::format( "Setting SSL protocol to {} (from RESINSIGHT_SSL_PROTOCOL)", sslProtocolEnv ) );
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
sslConfig.setProtocol( protocol );
QSslConfiguration::setDefaultConfiguration( sslConfig );
}
else
{
RiaLogging::warning( QString( "Invalid RESINSIGHT_SSL_PROTOCOL value: %1" ).arg( sslProtocolEnv ) );
RiaLogging::warning( std::format( "Invalid RESINSIGHT_SSL_PROTOCOL value: {}", sslProtocolEnv ) );
}
}
@@ -105,20 +106,20 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent,
m_networkAccessManager = new QNetworkAccessManager( this );
m_authCodeFlow->setNetworkAccessManager( m_networkAccessManager );
RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() );
RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() );
RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString().toStdString() );
RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString().toStdString() );
RiaLogging::debug( "Cloud config:" );
RiaLogging::debug( " server: '" + server + "'" );
RiaLogging::debug( " authority: '" + authority + "'" );
RiaLogging::debug( " scopes: '" + scopes + "'" );
RiaLogging::debug( " client id: '" + clientId + "'" );
RiaLogging::debug( std::format( " server: '{}'", server ) );
RiaLogging::debug( std::format( " authority: '{}'", authority ) );
RiaLogging::debug( std::format( " scopes: '{}'", scopes ) );
RiaLogging::debug( std::format( " client id: '{}'", clientId ) );
connect( m_authCodeFlow,
&QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
[]( QUrl url )
{
RiaLogging::info( "Authorize with url: " + url.toString() );
RiaLogging::info( "Authorize with url: " + url.toString().toStdString() );
QUrlQuery query( url );
url.setQuery( query );
QDesktopServices::openUrl( url );
@@ -136,7 +137,7 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent,
auto replyHandler = new RiaOAuthHttpServerReplyHandler( port, this );
m_authCodeFlow->setReplyHandler( replyHandler );
RiaLogging::debug( "Server callback: " + replyHandler->callback() );
RiaLogging::debug( "Server callback: " + replyHandler->callback().toStdString() );
connect( m_authCodeFlow, SIGNAL( granted() ), this, SLOT( accessGranted() ) );
@@ -173,7 +174,7 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent,
this,
[&]( const QDateTime& expiration )
{
RiaLogging::debug( QString( "Access token expiration changed: %1" ).arg( expiration.toString() ) );
RiaLogging::debug( std::format( "Access token expiration changed: {}", expiration.toString() ) );
exportTokenToFile();
} );
}
@@ -209,7 +210,7 @@ void RiaCloudConnector::accessGranted()
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri )
{
RiaLogging::debug( "Cloud Error Received: " + error + ". Description: " + errorDescription );
RiaLogging::debug( std::format( "Cloud Error Received: {}. Description: {}", error, errorDescription ) );
}
//--------------------------------------------------------------------------------------------------
@@ -220,7 +221,7 @@ void RiaCloudConnector::authorizationCallbackReceived( const QVariantMap& data )
RiaLogging::debug( "Authorization callback received:" );
for ( const auto& [key, value] : data.toStdMap() )
{
RiaLogging::debug( " Key: " + key + " Value: " + value.toString() );
RiaLogging::debug( std::format( " Key: {} Value: {}", key, value.toString() ) );
}
}
@@ -25,6 +25,7 @@
#include "RiaPreferencesOpenTelemetry.h"
#include "RiaPreferencesOsdu.h"
#include "RiaPreferencesSumo.h"
#include "RiaQStringFormatter.h"
#include <QDir>
#include <QFile>
@@ -188,7 +189,7 @@ void RiaConnectorTools::readCloudConfigFiles( RiaPreferences* preferences )
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( filePath );
if ( !keyValuePairs.empty() )
{
RiaLogging::debug( QString( "Imported OSDU configuration from : '%1'" ).arg( filePath ) );
RiaLogging::debug( std::format( "Imported OSDU configuration from : '{}'", filePath ) );
preferences->osduPreferences()->setData( keyValuePairs, filePath );
break;
}
@@ -200,7 +201,7 @@ void RiaConnectorTools::readCloudConfigFiles( RiaPreferences* preferences )
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( filePath );
if ( !keyValuePairs.empty() )
{
RiaLogging::debug( QString( "Imported SUMO configuration from : '%1'" ).arg( filePath ) );
RiaLogging::debug( std::format( "Imported SUMO configuration from : '{}'", filePath ) );
preferences->sumoPreferences()->setData( keyValuePairs, filePath );
break;
}
@@ -212,7 +213,7 @@ void RiaConnectorTools::readCloudConfigFiles( RiaPreferences* preferences )
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( filePath );
if ( !keyValuePairs.empty() )
{
RiaLogging::debug( QString( "Imported OpenTelemetry configuration from : '%1'" ).arg( filePath ) );
RiaLogging::debug( std::format( "Imported OpenTelemetry configuration from : '{}'", filePath ) );
RiaPreferencesOpenTelemetry::current()->setData( keyValuePairs, filePath );
break;
}
@@ -20,6 +20,7 @@
#include "RiaCloudDefines.h"
#include "RiaLogging.h"
#include "RiaOsduDefines.h"
#include "RiaQStringFormatter.h"
#include <QJsonDocument>
#include <QJsonObject>
@@ -120,7 +121,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& server, const QString
{
QString errorMessage =
QString( "Download failed for fields by name (%1). Error: %2" ).arg( fieldName ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
} );
}
@@ -156,7 +157,7 @@ void RiaOsduConnector::requestWellboresByFieldId( const QString& server, const Q
{
QString errorMessage =
QString( "Request failed for wellbores for field (%1). Error: %2" ).arg( fieldId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
} );
}
@@ -210,7 +211,7 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server,
{
QString errorMessage =
QString( "Request failed for well logs by wellbore (%1). Error: %2" ).arg( wellboreId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
} );
}
@@ -249,7 +250,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser
{
QString errorMessage =
QString( "Request failed for well trajectory by wellbore (%1). Error: %2" ).arg( wellboreId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
} );
}
@@ -340,7 +341,7 @@ void RiaOsduConnector::parseFields( QNetworkReply* reply )
m_fields.push_back( OsduField{ id, kind, fieldName } );
}
RiaLogging::debug( QString( "Found %1 fields." ).arg( m_fields.size() ) );
RiaLogging::debug( std::format( "Found {} fields.", m_fields.size() ) );
}
emit fieldsFinished();
@@ -389,7 +390,7 @@ void RiaOsduConnector::parseWellboresByFieldId( QNetworkReply* reply, const QStr
if ( std::isinf( datumElevation ) )
{
RiaLogging::warning( QString( "Missing datum elevation for well bore '%1'. Id: %2" ).arg( name ).arg( id ) );
RiaLogging::warning( std::format( "Missing datum elevation for well bore '{}'. Id: {}", name, id ) );
datumElevation = 0.0;
}
@@ -401,7 +402,7 @@ void RiaOsduConnector::parseWellboresByFieldId( QNetworkReply* reply, const QStr
}
else
{
RiaLogging::error( "Failed to download wellbores for field with id " + fieldId + ": " + reply->errorString() );
RiaLogging::error( std::format( "Failed to download wellbores for field with id {}: {}", fieldId, reply->errorString() ) );
}
}
@@ -480,7 +481,7 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb
double samplingStop = dataObj["SamplingStop"].toDouble( std::numeric_limits<double>::infinity() );
QJsonArray curvesArray = dataObj["Curves"].toArray();
RiaLogging::debug( QString( "Curves for '%1':" ).arg( id ) );
RiaLogging::debug( std::format( "Curves for '{}':", id ) );
std::vector<OsduWellLogChannel> channels;
for ( const QJsonValue& curve : curvesArray )
@@ -495,8 +496,7 @@ void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellb
QString unit = curve["CurveUnit"].toString();
QString depthUnit = curve["DepthUnit"].toString();
RiaLogging::debug(
QString( "%1: '%2' (%3 - %4)" ).arg( curveId ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) );
RiaLogging::debug( std::format( "{}: '{}' ({} - {})", curveId, curveDescription, curveTopDepth, curveBaseDepth ) );
channels.push_back( OsduWellLogChannel{ .id = curveId,
.mnemonic = mnemonic,
.description = curveDescription,
@@ -632,7 +632,7 @@ std::vector<OsduWellboreTrajectory> RiaOsduConnector::wellboreTrajectories( cons
void RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId )
{
QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId );
RiaLogging::debug( "Wellbore trajectory URL: " + url );
RiaLogging::debug( "Wellbore trajectory URL: " + url.toStdString() );
requestParquetDataByUrl( url, wellboreTrajectoryId );
}
@@ -642,7 +642,7 @@ void RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString&
void RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId )
{
QString url = constructWellLogDownloadUrl( m_server, wellLogId );
RiaLogging::debug( "Well log URL: " + url );
RiaLogging::debug( "Well log URL: " + url.toStdString() );
requestParquetDataByUrl( url, wellLogId );
}
@@ -661,7 +661,7 @@ void RiaOsduConnector::requestParquetDataByUrl( const QString& url, const QStrin
std::pair<QByteArray, QString> RiaOsduConnector::requestWellboreTrajectoryParquetDataByIdBlocking( const QString& wellboreTrajectoryId )
{
QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId );
RiaLogging::debug( "Wellbore trajectory URL: " + url );
RiaLogging::debug( "Wellbore trajectory URL: " + url.toStdString() );
return requestParquetDataByUrlBlocking( url, wellboreTrajectoryId );
}
@@ -672,7 +672,7 @@ std::pair<QByteArray, QString> RiaOsduConnector::requestWellboreTrajectoryParque
std::pair<QByteArray, QString> RiaOsduConnector::requestWellLogParquetDataByIdBlocking( const QString& wellLogId )
{
QString url = constructWellLogDownloadUrl( m_server, wellLogId );
RiaLogging::debug( "Well log URL: " + url );
RiaLogging::debug( "Well log URL: " + url.toStdString() );
return requestParquetDataByUrlBlocking( url, wellLogId );
}
@@ -698,7 +698,7 @@ std::pair<QByteArray, QString> RiaOsduConnector::requestParquetDataByUrlBlocking
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token, const QString& id )
{
RiaLogging::info( "Requesting download of parquet from: " + url );
RiaLogging::info( "Requesting download of parquet from: " + url.toStdString() );
auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaCloudDefines::contentTypeParquet() );
m_repliesMutex.lock();
@@ -712,13 +712,13 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da
if ( reply->error() == QNetworkReply::NoError )
{
QByteArray contents = reply->readAll();
RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) );
RiaLogging::info( std::format( "Download succeeded: {} bytes.", contents.length() ) );
emit parquetDownloadFinished( contents, "", id );
}
else
{
QString errorMessage = "Request failed: " + url + " failed." + reply->errorString();
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
emit parquetDownloadFinished( QByteArray(), errorMessage, id );
}
} );
@@ -22,6 +22,7 @@
#include "RiaLogging.h"
#include "RiaOAuthHttpServerReplyHandler.h"
#include "RiaOsduDefines.h"
#include "RiaQStringFormatter.h"
#include <QEventLoop>
#include <QJsonArray>
@@ -284,11 +285,11 @@ void RiaSumoConnector::parseEnsembleNames( QNetworkReply* reply, const SumoCaseI
m_ensembleNames.push_back( { caseId, ensembleName } );
}
RiaLogging::debug( QString( "Ensemble count : %1" ).arg( m_ensembleNames.size() ) );
RiaLogging::debug( std::format( "Ensemble count : {}", m_ensembleNames.size() ) );
}
else
{
RiaLogging::error( QString( "Request ensemble names failed: : '%s'" ).arg( reply->errorString() ) );
RiaLogging::error( std::format( "Request ensemble names failed: : '%s'", reply->errorString() ) );
}
emit ensembleNamesFinished();
@@ -524,7 +525,7 @@ void RiaSumoConnector::requestParametersBlobIdForEnsemble( const SumoCaseId& cas
}
else
{
RiaLogging::error( QString( "Request parameters failed: : '%s'" ).arg( reply->errorString() ) );
RiaLogging::error( std::format( "Request parameters failed: : '%s'", reply->errorString() ) );
}
} );
}
@@ -624,13 +625,13 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId )
else
{
QString errorMessage = "Not able to parse and interpret valid redirect Url";
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
}
else
{
QString errorMessage = "Download failed: " + url + " failed." + reply->errorString();
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
} );
}
@@ -640,7 +641,7 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId )
//--------------------------------------------------------------------------------------------------
void RiaSumoConnector::requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri )
{
RiaLogging::debug( QString( "Requesting blob. Id: %1 Redirect URL: %2" ).arg( blobId ).arg( redirectUri ) );
RiaLogging::debug( std::format( "Requesting blob. Id: {} Redirect URL: {}", blobId, redirectUri ) );
requestTokenBlocking();
@@ -658,7 +659,7 @@ void RiaSumoConnector::requestBlobByRedirectUri( const QString& blobId, const QS
auto contents = reply->readAll();
QString msg = "Received data from : " + redirectUri;
RiaLogging::info( msg );
RiaLogging::info( msg.toStdString() );
parquetDownloadComplete( blobId, contents, redirectUri );
@@ -667,7 +668,7 @@ void RiaSumoConnector::requestBlobByRedirectUri( const QString& blobId, const QS
else
{
QString errorMessage = "Download failed: " + redirectUri + " failed." + reply->errorString();
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
emit parquetDownloadFinished( {}, redirectUri );
}
@@ -797,12 +798,12 @@ void RiaSumoConnector::parseAssets( QNetworkReply* reply )
for ( auto a : m_assets )
{
RiaLogging::info( QString( "Asset: %1" ).arg( a.name ) );
RiaLogging::info( std::format( "Asset: {}", a.name ) );
}
}
else
{
RiaLogging::error( QString( "Request assets failed: : '%s'" ).arg( reply->errorString() ) );
RiaLogging::error( std::format( "Request assets failed: : '%s'", reply->errorString() ) );
}
emit assetsFinished();
@@ -838,11 +839,11 @@ void RiaSumoConnector::parseCases( QNetworkReply* reply )
m_cases.push_back( SumoCase{ SumoCaseId( id ), kind, fieldName } );
}
RiaLogging::debug( QString( "Case count : %1" ).arg( m_cases.size() ) );
RiaLogging::debug( std::format( "Case count : {}", m_cases.size() ) );
}
else
{
RiaLogging::error( QString( "Request cases failed: : '%s'" ).arg( reply->errorString() ) );
RiaLogging::error( std::format( "Request cases failed: : '%s'", reply->errorString() ) );
}
emit casesFinished();
@@ -875,7 +876,7 @@ void RiaSumoConnector::parseVectorNames( QNetworkReply* reply, const SumoCaseId&
}
else
{
RiaLogging::error( QString( "Request vector names failed: : '%s'" ).arg( reply->errorString() ) );
RiaLogging::error( std::format( "Request vector names failed: : '%s'", reply->errorString() ) );
}
emit vectorNamesFinished();
@@ -973,7 +974,7 @@ QNetworkReply* RiaSumoConnector::makeDownloadRequest( const QString& url, const
//--------------------------------------------------------------------------------------------------
void RiaSumoConnector::requestParquetData( const QString& url, const QString& token )
{
RiaLogging::info( "Requesting download of parquet from: " + url );
RiaLogging::info( "Requesting download of parquet from: " + url.toStdString() );
auto reply = makeDownloadRequest( url, token, RiaCloudDefines::contentTypeJson() );
connect( reply,
@@ -983,13 +984,13 @@ void RiaSumoConnector::requestParquetData( const QString& url, const QString& to
if ( reply->error() == QNetworkReply::NoError )
{
QByteArray contents = reply->readAll();
RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) );
RiaLogging::info( std::format( "Download succeeded: {} bytes.", contents.length() ) );
emit parquetDownloadFinished( contents, "" );
}
else
{
QString errorMessage = "Download failed: " + url + " failed." + reply->errorString();
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
emit parquetDownloadFinished( QByteArray(), errorMessage );
}
} );
@@ -64,7 +64,7 @@ std::vector<RimSummaryCase*> createSummaryCasesFromFiles( const QStringList& fil
if ( fileSelector.foundErrors() )
{
QString errorMessage = fileSelector.createCombinedErrorMessage();
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
}
else
@@ -216,7 +216,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fil
if ( selector.foundErrors() )
{
QString errorMessage = selector.createCombinedErrorMessage();
RiaLogging::error( errorMessage );
RiaLogging::error( errorMessage.toStdString() );
}
project->activeOilField()->completionTemplateCollection()->setDefaultUnitSystemBasedOnLoadedCases();
@@ -166,11 +166,11 @@ void RiaDefaultConsoleLogger::writeToConsole( const std::string& str )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaLogging::setLastMessage( const QString& message )
void RiaLogging::setLastMessage( std::string_view message )
{
#pragma omp critical( critical_section_logging )
{
sm_lastMessage = message;
sm_lastMessage.assign( message );
sm_lastMessageTime = std::chrono::high_resolution_clock::now();
}
}
@@ -178,7 +178,7 @@ void RiaLogging::setLastMessage( const QString& message )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaLogging::isSameMessage( const QString& message )
bool RiaLogging::isSameMessage( std::string_view message )
{
bool isSame = false;
@@ -199,6 +199,15 @@ bool RiaLogging::isSameMessage( const QString& message )
return isSame;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaLogging::isKeywordEnabled( std::string_view keyword )
{
return RiaPreferencesSystem::current()->isLoggingActivatedForKeyword(
QString::fromUtf8( keyword.data(), static_cast<qsizetype>( keyword.size() ) ) );
}
//==================================================================================================
//
//
@@ -206,7 +215,7 @@ bool RiaLogging::isSameMessage( const QString& message )
//==================================================================================================
std::vector<std::unique_ptr<RiaLogger>> RiaLogging::sm_logger;
QString RiaLogging::sm_lastMessage;
std::string RiaLogging::sm_lastMessage;
std::chrono::time_point<std::chrono::high_resolution_clock> RiaLogging::sm_lastMessageTime;
//--------------------------------------------------------------------------------------------------
@@ -264,84 +273,76 @@ std::optional<RILogLevel> RiaLogging::parseLogLevelString( const QString& logLev
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaLogging::error( const QString& message, const QString logKeyword )
void RiaLogging::error( std::string_view message, std::string_view logKeyword )
{
if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return;
if ( !isKeywordEnabled( logKeyword ) ) return;
if ( isSameMessage( message ) ) return;
const std::string buf{ message };
for ( const auto& logger : sm_logger )
{
if ( logger && logger->level() >= int( RILogLevel::RI_LL_ERROR ) )
{
#pragma omp critical( critical_section_logging )
logger->error( message.toLatin1().constData() );
logger->error( buf.c_str() );
}
}
setLastMessage( message );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaLogging::warning( const QString& message, const QString logKeyword )
void RiaLogging::warning( std::string_view message, std::string_view logKeyword )
{
if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return;
if ( !isKeywordEnabled( logKeyword ) ) return;
if ( isSameMessage( message ) ) return;
const std::string buf{ message };
for ( const auto& logger : sm_logger )
{
if ( logger && logger->level() >= int( RILogLevel::RI_LL_WARNING ) )
{
#pragma omp critical( critical_section_logging )
logger->warning( message.toLatin1().constData() );
logger->warning( buf.c_str() );
}
}
setLastMessage( message );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaLogging::info( const QString& message, const QString logKeyword )
void RiaLogging::info( std::string_view message, std::string_view logKeyword )
{
if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return;
if ( !isKeywordEnabled( logKeyword ) ) return;
if ( isSameMessage( message ) ) return;
const std::string buf{ message };
for ( const auto& logger : sm_logger )
{
if ( logger && logger->level() >= int( RILogLevel::RI_LL_INFO ) )
{
#pragma omp critical( critical_section_logging )
logger->info( message.toLatin1().constData() );
logger->info( buf.c_str() );
}
}
setLastMessage( message );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaLogging::debug( const QString& message, const QString logKeyword )
void RiaLogging::debug( std::string_view message, std::string_view logKeyword )
{
if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return;
if ( !isKeywordEnabled( logKeyword ) ) return;
if ( isSameMessage( message ) ) return;
const std::string buf{ message };
for ( const auto& logger : sm_logger )
{
if ( logger && logger->level() >= int( RILogLevel::RI_LL_DEBUG ) )
{
#pragma omp critical( critical_section_logging )
logger->debug( message.toLatin1().constData() );
logger->debug( buf.c_str() );
}
}
setLastMessage( message );
}
@@ -68,21 +68,22 @@ public:
static RILogLevel logLevelBasedOnPreferences();
static std::optional<RILogLevel> parseLogLevelString( const QString& logLevelString );
static void error( const QString& message, const QString logKeyword = "" );
static void warning( const QString& message, const QString logKeyword = "" );
static void info( const QString& message, const QString logKeyword = "" );
static void debug( const QString& message, const QString logKeyword = "" );
static void error( std::string_view message, std::string_view logKeyword = "" );
static void warning( std::string_view message, std::string_view logKeyword = "" );
static void info( std::string_view message, std::string_view logKeyword = "" );
static void debug( std::string_view message, std::string_view logKeyword = "" );
static std::chrono::time_point<std::chrono::high_resolution_clock> currentTime();
static void logElapsedTime( std::string_view message, const std::chrono::time_point<std::chrono::high_resolution_clock>& startTime );
private:
static void setLastMessage( const QString& message );
static bool isSameMessage( const QString& message );
static void setLastMessage( std::string_view message );
static bool isSameMessage( std::string_view message );
static bool isKeywordEnabled( std::string_view keyword );
private:
static std::vector<std::unique_ptr<RiaLogger>> sm_logger;
static QString sm_lastMessage;
static std::string sm_lastMessage;
static std::chrono::time_point<std::chrono::high_resolution_clock> sm_lastMessageTime;
};
@@ -40,7 +40,7 @@ bool createTableIfNeeded()
"content TEXT)" ) )
{
QString txt = "Error creating table:" + query.lastError().text();
RiaLogging::error( txt );
RiaLogging::error( txt.toStdString() );
return false;
}
@@ -60,7 +60,7 @@ bool insertContent( const QString& content )
if ( !query.exec() )
{
QString txt = "Error saving file content to database:" + query.lastError().text();
RiaLogging::error( txt );
RiaLogging::error( txt.toStdString() );
return false;
}
@@ -74,7 +74,7 @@ bool deleteOldRecords( int maximumRecordCount )
QSqlQuery countQuery( "SELECT COUNT(*) FROM file_versions" );
if ( !countQuery.exec() || !countQuery.next() )
{
RiaLogging::error( "Error counting records: " + countQuery.lastError().text() );
RiaLogging::error( "Error counting records: " + countQuery.lastError().text().toStdString() );
return false;
}
@@ -89,7 +89,7 @@ bool deleteOldRecords( int maximumRecordCount )
if ( !query.exec() )
{
QString txt = "Error deleting old records:" + query.lastError().text();
RiaLogging::error( txt );
RiaLogging::error( txt.toStdString() );
return false;
}
@@ -122,7 +122,7 @@ bool appendTextToDatabase( const QString& databaseFilePath, int maximumRecordCou
if ( !db.open() )
{
QString txt = "Error opening database:" + db.lastError().text();
RiaLogging::error( txt );
RiaLogging::error( txt.toStdString() );
return false;
}
@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <format>
#include <string_view>
#include <QByteArray>
#include <QString>
// std::formatter specialization for QString. Include this header in any
// translation unit that calls std::format with QString arguments.
//
// QString is encoded as UTF-8 before being formatted as a string_view; the
// QByteArray holding the encoded bytes lives for the duration of the format()
// call, which writes synchronously to the output iterator.
template <>
struct std::formatter<QString> : std::formatter<std::string_view>
{
auto format( const QString& value, std::format_context& ctx ) const
{
const QByteArray bytes = value.toUtf8();
return std::formatter<std::string_view>::format( std::string_view{ bytes.constData(), static_cast<size_t>( bytes.size() ) }, ctx );
}
};
@@ -54,7 +54,7 @@ namespace internal
QFile file( filename );
if ( !file.open( QIODevice::WriteOnly ) )
{
RiaLogging::error( "Couldn't open file : " + filename );
RiaLogging::error( "Couldn't open file : " + filename.toStdString() );
return;
}
file.write( jsonDoc.toJson() );
@@ -68,7 +68,7 @@ namespace internal
QFile file( filename );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
RiaLogging::error( "Couldn't open file : " + filename );
RiaLogging::error( "Couldn't open file : " + filename.toStdString() );
return {};
}
@@ -77,7 +77,7 @@ namespace internal
if ( !jsonDoc.isObject() )
{
RiaLogging::error( "Invalid JSON format in : " + filename );
RiaLogging::error( "Invalid JSON format in : " + filename.toStdString() );
return {};
}
@@ -26,6 +26,7 @@
#include "RiaPlotWindowRedrawScheduler.h"
#include "RiaPreferences.h"
#include "RiaProjectModifier.h"
#include "RiaQStringFormatter.h"
#include "RiaRegressionTest.h"
#include "RiaTextFileCompare.h"
#include "RiaTextStringTools.h"
@@ -85,7 +86,7 @@ void logInfoTextWithTimeInSeconds( const QElapsedTimer& time, const QString& msg
QString timeText = QString( "(%1 s) " ).arg( timeRunning, 0, 'f', 1 );
RiaLogging::info( timeText + msg );
RiaLogging::info( std::format( "{}{}", timeText, msg ) );
QApplication::processEvents();
}
@@ -189,7 +190,7 @@ void RiaRegressionTestRunner::runRegressionTest()
}
RiaLogging::info( "--------------------------------------------------" );
RiaLogging::info( QTime::currentTime().toString() + ": Launching regression tests" );
RiaLogging::info( std::format( "{}: Launching regression tests", QTime::currentTime().toString() ) );
RiaLogging::info( "--------------------------------------------------" );
QElapsedTimer timeStamp;
@@ -209,7 +210,7 @@ void RiaRegressionTestRunner::runRegressionTest()
if ( !testPrefsFile.isEmpty() )
{
RiaPreferences::current()->importPreferenceValuesFromFile( testPrefsFile );
RiaLogging::info( "Loaded test-specific preferences from: " + testPrefsFile );
RiaLogging::info( "Loaded test-specific preferences from: " + testPrefsFile.toStdString() );
}
bool anyCommandFilesExecuted = findAndExecuteCommandFiles( testCaseFolder, regressionTestConfig, htmlReportFileName );
@@ -282,8 +283,9 @@ void RiaRegressionTestRunner::runRegressionTest()
}
else
{
RiaLogging::error( "Could not find a regression test file named : " + testCaseFolder.absolutePath() + "/" +
regTestProjectName + ".rsp" );
RiaLogging::error( std::format( "Could not find a regression test file named : {}/{}.rsp",
testCaseFolder.absolutePath(),
regTestProjectName ) );
}
}
@@ -320,7 +322,7 @@ void RiaRegressionTestRunner::runRegressionTest()
{
auto timeText = QString( "(%1 s) " ).arg( testDuration, 5, 'f', 1 );
auto logInfo = QString( "%1 %2 %3 %4" ).arg( timeText ).arg( beforeMemory ).arg( afterMemory ).arg( name );
RiaLogging::info( logInfo );
RiaLogging::info( logInfo.toStdString() );
}
// Invoke git diff
@@ -415,7 +417,7 @@ bool RiaRegressionTestRunner::findAndExecuteCommandFiles( const QDir&
QFile file( commandFile );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
RiaLogging::error( "Failed to open command file : " + commandFile );
RiaLogging::error( "Failed to open command file : " + commandFile.toStdString() );
}
else
{
@@ -470,13 +470,13 @@ std::set<int> RiaStdStringTools::valuesFromRangeSelection( const std::string& s
{
QString str = QString( "Failed to convert text string \" %1 \" to list of integers : " ).arg( QString::fromStdString( s ) ) +
QString::fromStdString( e.what() );
RiaLogging::error( str );
RiaLogging::error( str.toStdString() );
}
catch ( ... )
{
QString str =
QString( "Failed to convert text string \" %1 \" to list of integers : Caught unknown exception" ).arg( QString::fromStdString( s ) );
RiaLogging::error( str );
RiaLogging::error( str.toStdString() );
}
return {};
@@ -565,13 +565,13 @@ std::set<int> RiaStdStringTools::valuesFromRangeSelection( const std::string& s,
{
QString str = QString( "Failed to convert text string \" %1 \" to list of integers : " ).arg( QString::fromStdString( s ) ) +
QString::fromStdString( e.what() );
RiaLogging::error( str );
RiaLogging::error( str.toStdString() );
}
catch ( ... )
{
QString str =
QString( "Failed to convert text string \" %1 \" to list of integers : Caught unknown exception" ).arg( QString::fromStdString( s ) );
RiaLogging::error( str );
RiaLogging::error( str.toStdString() );
}
return {};
@@ -19,6 +19,7 @@
#include "RiaToCafLogging.h"
#include "RiaLogging.h"
#include "RiaQStringFormatter.h"
//--------------------------------------------------------------------------------------------------
// Static member definitions
@@ -55,7 +56,7 @@ void RiaToCafLoggingBridge::setLevel( int logLevel )
//--------------------------------------------------------------------------------------------------
void RiaToCafLoggingBridge::error( const QString& message )
{
RiaLogging::error( QString( "CAF: %1" ).arg( message ) );
RiaLogging::error( std::format( "CAF: {}", message ) );
}
//--------------------------------------------------------------------------------------------------
@@ -63,7 +64,7 @@ void RiaToCafLoggingBridge::error( const QString& message )
//--------------------------------------------------------------------------------------------------
void RiaToCafLoggingBridge::warning( const QString& message )
{
RiaLogging::warning( QString( "CAF: %1" ).arg( message ) );
RiaLogging::warning( std::format( "CAF: {}", message ) );
}
//--------------------------------------------------------------------------------------------------
@@ -71,7 +72,7 @@ void RiaToCafLoggingBridge::warning( const QString& message )
//--------------------------------------------------------------------------------------------------
void RiaToCafLoggingBridge::info( const QString& message )
{
RiaLogging::info( QString( "CAF: %1" ).arg( message ) );
RiaLogging::info( std::format( "CAF: {}", message ) );
}
//--------------------------------------------------------------------------------------------------
@@ -79,7 +80,7 @@ void RiaToCafLoggingBridge::info( const QString& message )
//--------------------------------------------------------------------------------------------------
void RiaToCafLoggingBridge::debug( const QString& message )
{
RiaLogging::debug( QString( "CAF: %1" ).arg( message ) );
RiaLogging::debug( std::format( "CAF: {}", message ) );
}
//--------------------------------------------------------------------------------------------------
@@ -57,7 +57,7 @@ RifEclipseSummaryAddress RiaSummaryAddressModifier::replaceTokenForCategory( con
"for region text : %1" )
.arg( QString::fromStdString( token ) );
RiaLogging::error( errorText );
RiaLogging::error( errorText.toStdString() );
}
else
{
@@ -73,7 +73,7 @@ RifEclipseSummaryAddress RiaSummaryAddressModifier::replaceTokenForCategory( con
"for region text : %1" )
.arg( QString::fromStdString( token ) );
RiaLogging::error( errorText );
RiaLogging::error( errorText.toStdString() );
}
else
{
@@ -89,7 +89,7 @@ RifEclipseSummaryAddress RiaSummaryAddressModifier::replaceTokenForCategory( con
"for aquifer text : %1" )
.arg( QString::fromStdString( token ) );
RiaLogging::error( errorText );
RiaLogging::error( errorText.toStdString() );
}
else
{
@@ -21,6 +21,7 @@
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaQStringFormatter.h"
#include "Summary/RiaSummaryAddressAnalyzer.h"
#include "Summary/RiaSummaryTools.h"
@@ -57,7 +58,7 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFil
QFile importFile( fileName );
if ( !importFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
RiaLogging::error( QString( "Create Plot from Template : Could not open the file: %1" ).arg( fileName ) );
RiaLogging::error( std::format( "Create Plot from Template : Could not open the file: {}", fileName ) );
return nullptr;
}
@@ -19,6 +19,7 @@
#include "Summary/RiaSummaryStringTools.h"
#include "RiaLogging.h"
#include "RiaQStringFormatter.h"
#include "RiaStdStringTools.h"
#include "RiaTextStringTools.h"
#include "Summary/RiaSummaryTools.h"
@@ -65,7 +66,7 @@ void RiaSummaryStringTools::splitAddressFiltersInGridAndSummary( RimSummaryCase*
}
else
{
RiaLogging::warning( "No summary or restart vectors matched \"" + address + "\"" );
RiaLogging::warning( std::format( "No summary or restart vectors matched \"{}\"", address ) );
}
}
}
@@ -20,6 +20,7 @@
#include "RiaLogging.h"
#include "RiaPreferencesOpenTelemetry.h"
#include "RiaQStringFormatter.h"
#include "RifJsonEncodeDecode.h"
#include <QCryptographicHash>
@@ -417,7 +418,7 @@ void RiaOpenTelemetryManager::reportCrash( int signalCode, const std::stacktrace
}
}
RiaLogging::error( QString( "Crash reported to OpenTelemetry (signal: %1)" ).arg( signalCode ) );
RiaLogging::error( std::format( "Crash reported to OpenTelemetry (signal: {})", signalCode ) );
}
//--------------------------------------------------------------------------------------------------
@@ -597,7 +598,7 @@ bool RiaOpenTelemetryManager::createExporter()
}
// Using Application Insights REST API for telemetry
RiaLogging::info( QString( "Application Insights REST API configured for production environment" ) );
RiaLogging::info( "Application Insights REST API configured for production environment" );
return true;
}
@@ -832,7 +833,7 @@ void RiaOpenTelemetryManager::handleError( TelemetryError error, const QString&
m_errorCallback( error, context );
}
RiaLogging::warning( QString( "OpenTelemetry error: %1" ).arg( context ) );
RiaLogging::warning( std::format( "OpenTelemetry error: {}", context ) );
}
//--------------------------------------------------------------------------------------------------