void Log::setFunction(const Function &function) { bunsan::log::remove_default_sink(); static std::mutex lock; static boost::shared_ptr<boost::log::sinks::sink> sink; std::lock_guard<std::mutex> lk(lock); const auto core = boost::log::core::get(); if (sink) { core->remove_sink(sink); sink.reset(); } sink = boost::make_shared<Sink>(function); boost::log::core::get()->add_sink(sink); }
static void purge_dead_sinks() { uint64_t now = util_time_now(); uint8_t purged_sinks = 0; for (int i = 0; i < list.nbr_sinks; i++) { if (now - list.sinks[i].last_heartbeat > (SINK_MANAGER_SINK_TIMEOUT * 1000)) { if (purged_sinks == 0) { log_info("Purge sinks:"); } log_infof(" %s - timed out. Uncontacted for %lus", inet_ntoa(list.sinks[i].ip), (now - list.sinks[i].last_heartbeat) / 1000); remove_sink(i); purged_sinks++; } } }