Skip to content

Commit

Permalink
Don't allow logger::log to throw exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jan 3, 2020
1 parent 42d3a92 commit 7fc8c2e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/log/logger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <fc/log/logger.hpp>
#include <fc/log/log_message.hpp>
#include <fc/log/appender.hpp>
#include <fc/exception/exception.hpp>
#include <fc/filesystem.hpp>
#include <unordered_map>
#include <string>
Expand Down Expand Up @@ -62,8 +63,17 @@ namespace fc {
std::unique_lock g( log_config::get().log_mutex );
m.get_context().append_context( my->_name );

for( auto itr = my->_appenders.begin(); itr != my->_appenders.end(); ++itr )
(*itr)->log( m );
for( auto itr = my->_appenders.begin(); itr != my->_appenders.end(); ++itr ) {
try {
(*itr)->log( m );
} catch( fc::exception& er ) {
std::cerr << "ERROR: logger::log fc::exception: " << er.to_detail_string() << std::endl;
} catch( const std::exception& e ) {
std::cerr << "ERROR: logger::log std::exception: " << e.what() << std::endl;
} catch( ... ) {
std::cerr << "ERROR: logger::log unknown exception: " << std::endl;
}
}

if( my->_additivity && my->_parent != nullptr) {
logger parent = my->_parent;
Expand Down

0 comments on commit 7fc8c2e

Please sign in to comment.