Skip to content

Commit

Permalink
Add error logger in InstanceMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Jan 4, 2024
1 parent 573f3c0 commit 1600857
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions libethereum/InstanceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );

Check warning on line 53 in libethereum/InstanceMonitor.cpp

View check run for this annotation

Codecov / codecov/patch

libethereum/InstanceMonitor.cpp#L51-L53

Added lines #L51 - L53 were not covered by tests
}
}
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion libethereum/InstanceMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) };
};

0 comments on commit 1600857

Please sign in to comment.