From 1600857ba45aeb2703235cc6c4d41ac3e973f14d Mon Sep 17 00:00:00 2001 From: badrogger Date: Thu, 4 Jan 2024 18:24:26 +0000 Subject: [PATCH] Add error logger in InstanceMonitor --- libethereum/InstanceMonitor.cpp | 12 ++++++------ libethereum/InstanceMonitor.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libethereum/InstanceMonitor.cpp b/libethereum/InstanceMonitor.cpp index b3a48a74b..d3dd72db1 100644 --- a/libethereum/InstanceMonitor.cpp +++ b/libethereum/InstanceMonitor.cpp @@ -47,9 +47,9 @@ void InstanceMonitor::initRotationParams( uint64_t _finishTimestamp ) { std::ofstream rotationInfoFile( m_rotationInfoFilePath.string() ); rotationInfoFile << rotationJson; - LOG( m_logger ) << "Set rotation time to " << _finishTimestamp; + LOG( m_info_logger ) << "Set rotation time to " << _finishTimestamp; } catch ( ... ) { - LOG( m_logger ) << "Setting rotation timestamp failed"; + LOG( m_error_logger ) << "Setting rotation timestamp failed"; throw_with_nested( std::runtime_error( "cannot save rotation timestamp" ) ); } } @@ -71,18 +71,18 @@ uint64_t InstanceMonitor::rotationTimestamp() const { try { auto rotationJson = nlohmann::json::parse( rotationInfoFile ); auto timestamp = rotationJson["timestamp"].get< uint64_t >(); - LOG( m_logger ) << "Rotation scheduled for " << timestamp; + LOG( m_info_logger ) << "Rotation scheduled for " << timestamp; return timestamp; } catch ( ... ) { - LOG( m_logger ) << "Rotation file is malformed or missing"; + LOG( m_error_logger ) << "Rotation file is malformed or missing"; throw InvalidRotationInfoFileException( m_rotationInfoFilePath ); } } void InstanceMonitor::reportExitTimeReached( bool _reached ) { if ( m_statusAndControl ) { - LOG( m_logger ) << "Setting ExitTimeReached = " << _reached; + LOG( m_info_logger ) << "Setting ExitTimeReached = " << _reached; m_statusAndControl->setExitState( StatusAndControl::ExitTimeReached, _reached ); } else - LOG( m_logger ) << "Simulating setting ExitTimeReached = " << _reached; + LOG( m_info_logger ) << "Simulating setting ExitTimeReached = " << _reached; } diff --git a/libethereum/InstanceMonitor.h b/libethereum/InstanceMonitor.h index 293a068f6..4e241ad4d 100644 --- a/libethereum/InstanceMonitor.h +++ b/libethereum/InstanceMonitor.h @@ -70,5 +70,6 @@ class InstanceMonitor { private: - mutable dev::Logger m_logger{ createLogger( dev::VerbosityInfo, "instance-monitor" ) }; + mutable dev::Logger m_info_logger{ createLogger( dev::VerbosityInfo, "instance-monitor" ) }; + mutable dev::Logger m_error_logger{ createLogger( dev::VerbosityError, "instance-monitor" ) }; };