Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7550 from EOSIO/sighup-logging-1.8
Browse files Browse the repository at this point in the history
Sighup logging - v1.8.x
  • Loading branch information
heifner committed Jun 28, 2019
2 parents b95786c + b15c93b commit 97d70ec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 30 deletions.
2 changes: 1 addition & 1 deletion libraries/appbase
7 changes: 1 addition & 6 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

using namespace eosio::chain::plugin_interface::compat;

namespace fc {
extern std::unordered_map<std::string,logger>& get_logger_map();
}

namespace eosio {
static appbase::abstract_plugin& _net_plugin = app().register_plugin<net_plugin>();

Expand Down Expand Up @@ -3077,8 +3073,7 @@ namespace eosio {
}

void net_plugin::handle_sighup() {
if(fc::get_logger_map().find(logger_name) != fc::get_logger_map().end())
logger = fc::get_logger_map()[logger_name];
fc::logger::update( logger_name, logger );
}

void net_plugin::plugin_shutdown() {
Expand Down
15 changes: 2 additions & 13 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ using std::vector;
using std::deque;
using boost::signals2::scoped_connection;

// HACK TO EXPOSE LOGGER MAP

namespace fc {
extern std::unordered_map<std::string,logger>& get_logger_map();
}

const fc::string logger_name("producer_plugin");
fc::logger _log;

Expand Down Expand Up @@ -875,13 +869,8 @@ void producer_plugin::plugin_shutdown() {
}

void producer_plugin::handle_sighup() {
auto& logger_map = fc::get_logger_map();
if(logger_map.find(logger_name) != logger_map.end()) {
_log = logger_map[logger_name];
}
if( logger_map.find(trx_trace_logger_name) != logger_map.end()) {
_trx_trace_log = logger_map[trx_trace_logger_name];
}
fc::logger::update( logger_name, _log );
fc::logger::update( trx_trace_logger_name, _trx_trace_log );
}

void producer_plugin::pause() {
Expand Down
12 changes: 3 additions & 9 deletions programs/nodeos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
using namespace appbase;
using namespace eosio;

namespace fc {
std::unordered_map<std::string,appender::ptr>& get_appender_map();
}

namespace detail {

void configure_logging(const bfs::path& config_path)
Expand All @@ -51,21 +47,19 @@ void configure_logging(const bfs::path& config_path)

void logging_conf_handler()
{
ilog("Received HUP. Reloading logging configuration.");
auto config_path = app().get_logging_conf();
ilog("Received HUP. Reloading logging configuration from ${p}.", ("p", config_path.string()));
if(fc::exists(config_path))
::detail::configure_logging(config_path);
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
fc::log_config::initialize_appenders( app().get_io_service() );
}

void initialize_logging()
{
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
fc::configure_logging(config_path); // intentionally allowing exceptions to escape
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
fc::log_config::initialize_appenders( app().get_io_service() );

app().set_sighup_callback(logging_conf_handler);
}
Expand Down

0 comments on commit 97d70ec

Please sign in to comment.