Skip to content

Commit

Permalink
fix: use logger from context to prevent use stale wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
antmat authored and 3Hren committed Aug 30, 2017
1 parent 5080add commit 012ae0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/cocaine/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class execution_unit_t {
// reused because of system fd rotation, but for low loads this will help a bit.
std::unique_ptr<asio::deadline_timer> m_cron;

context_t& context;

public:
explicit
execution_unit_t(context_t& context);
Expand Down
10 changes: 6 additions & 4 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ execution_unit_t::execution_unit_t(context_t& context):
m_chamber(new chamber_t("core/asio", m_asio)),
m_log(context.log("core/asio", {{"engine", m_chamber->thread_id()}})),
m_metrics(context.metrics_hub()),
m_cron(new asio::deadline_timer(*m_asio))
m_cron(new asio::deadline_timer(*m_asio)),
context(context)
{
m_asio->post(std::bind(&gc_action_t::operator(),
std::make_shared<gc_action_t>(this, boost::posix_time::seconds(kCollectionInterval))
Expand Down Expand Up @@ -179,10 +180,11 @@ execution_unit_t::attach(std::unique_ptr<Socket> ptr, const dispatch_ptr_t& disp
remote_endpoint = "<unknown>";
}

std::unique_ptr<logging::logger_t> log(new blackhole::wrapper_t(*m_log, {
auto log = context.log("core/asio/session", {
{"endpoint", remote_endpoint },
{"service", dispatch ? dispatch->name() : "<none>"}
}));
{"service", dispatch ? dispatch->name() : "<none>"},
{"engine", m_chamber->thread_id()}
});

COCAINE_LOG_DEBUG(log, "attached connection to engine, load: {:.2f}%", utilization() * 100);

Expand Down

0 comments on commit 012ae0c

Please sign in to comment.