void raft_set_callbacks(raft_server_t* me_, raft_cbs_t* funcs, void* udata) { raft_server_private_t* me = (raft_server_private_t*)me_; memcpy(&me->cb, funcs, sizeof(raft_cbs_t)); me->udata = udata; log_set_callbacks(me->log, &me->cb, me_); }
void spark::LogManager::removeHandler(LogHandler *handler) { const auto it = std::find(handlers_.begin(), handlers_.end(), handler); if (it != handlers_.end()) { if (handlers_.size() == 1) { log_set_callbacks(nullptr, nullptr, nullptr, nullptr); // Reset system callbacks } handlers_.erase(it); } }
// spark::LogManager void spark::LogManager::addHandler(LogHandler *handler) { const auto it = std::find(handlers_.cbegin(), handlers_.cend(), handler); if (it == handlers_.end()) { handlers_.push_back(handler); if (handlers_.size() == 1) { log_set_callbacks(logMessage, logWrite, logEnabled, nullptr); // Set system callbacks } } }