diff --git a/include/opendht/utils.h b/include/opendht/utils.h index 19154ed579d8e531cc9d1c4380fe6ad225450e70..ac9e927e8df75fd6fd4fefae436a02af0b77e128 100644 --- a/include/opendht/utils.h +++ b/include/opendht/utils.h @@ -132,7 +132,7 @@ private: struct Logger { LogMethod DEBUG = NOLOG; LogMethod WARN = NOLOG; - LogMethod ERROR = NOLOG; + LogMethod ERR = NOLOG; }; // Serialization related definitions and utility functions diff --git a/src/dht.cpp b/src/dht.cpp index 1e8c2accd21be5bf2455bde59b1cd3767d6e2d40..ce4e24f3d0a11bdc8558563d0dec915e7fb3a0a9 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -331,7 +331,7 @@ Dht::setLoggers(LogMethod&& error, LogMethod&& warn, LogMethod&& debug) { DHT_LOG.DEBUG = std::move(debug); DHT_LOG.WARN = std::move(warn); - DHT_LOG.ERROR = std::move(error); + DHT_LOG.ERR = std::move(error); } NodeStatus @@ -1109,7 +1109,7 @@ Dht::bootstrapSearch(Dht::Search& sr) return; auto b = list.findBucket(sr.id); if (b == list.end()) { - DHT_LOG.ERROR("No bucket"); + DHT_LOG.ERR("No bucket"); return; } @@ -1152,7 +1152,7 @@ std::shared_ptr<Dht::Search> Dht::search(const InfoHash& id, sa_family_t af, GetCallback callback, DoneCallback done_callback, Value::Filter filter) { if (!isRunning(af)) { - DHT_LOG.ERROR("[search %s IPv%c] unsupported protocol", id.toString().c_str(), (af == AF_INET) ? '4' : '6'); + DHT_LOG.ERR("[search %s IPv%c] unsupported protocol", id.toString().c_str(), (af == AF_INET) ? '4' : '6'); if (done_callback) done_callback(false, {}); return {}; @@ -1255,7 +1255,7 @@ Dht::announce(const InfoHash& id, sa_family_t af, std::shared_ptr<Value> value, scheduler.edit(sr->nextSearchStep, scheduler.time()); //TODO //if (tm < search_time) { - // DHT_LOG.ERROR("[search %s IPv%c] search_time is now in %lfs", sr->id.toString().c_str(),l + // DHT_LOG.ERR("[search %s IPv%c] search_time is now in %lfs", sr->id.toString().c_str(),l // (sr->af == AF_INET) ? '4' : '6', print_dt(tm-clock::now())); // search_time = tm; //} @@ -1267,7 +1267,7 @@ Dht::listenTo(const InfoHash& id, sa_family_t af, GetCallback cb, Value::Filter const auto& now = scheduler.time(); if (!isRunning(af)) return 0; - // DHT_LOG.ERROR("[search %s IPv%c] search_time is now in %lfs", sr->id.toString().c_str(), (sr->af == AF_INET) ? '4' : '6', print_dt(tm-clock::now())); + // DHT_LOG.ERR("[search %s IPv%c] search_time is now in %lfs", sr->id.toString().c_str(), (sr->af == AF_INET) ? '4' : '6', print_dt(tm-clock::now())); //DHT_LOG.WARN("listenTo %s", id.toString().c_str()); auto& srs = af == AF_INET ? searches4 : searches6; @@ -1275,7 +1275,7 @@ Dht::listenTo(const InfoHash& id, sa_family_t af, GetCallback cb, Value::Filter std::shared_ptr<Search> sr = (srp == srs.end()) ? search(id, af, nullptr, nullptr) : srp->second; if (!sr) throw DhtException("Can't create search"); - DHT_LOG.ERROR("[search %s IPv%c] listen", id.toString().c_str(), (af == AF_INET) ? '4' : '6'); + DHT_LOG.ERR("[search %s IPv%c] listen", id.toString().c_str(), (af == AF_INET) ? '4' : '6'); sr->done = false; auto token = ++sr->listener_token; sr->listeners.emplace(token, LocalListener{f, cb}); @@ -2250,7 +2250,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc try { network_engine.processMessage(buf, buflen, from, fromlen); } catch (const std::exception& e) { - DHT_LOG.ERROR("Can't parse message from %s: %s", print_addr(from, fromlen).c_str(), e.what()); + DHT_LOG.ERR("Can't parse message from %s: %s", print_addr(from, fromlen).c_str(), e.what()); //auto code = e.getCode(); //if (code == DhtProtocolException::INVALID_TID_SIZE or code == DhtProtocolException::WRONG_NODE_INFO_BUF_LEN) { /* This is really annoying, as it means that we will @@ -2367,7 +2367,7 @@ Dht::importValues(const std::vector<ValuesExport>& import) val_time = time_point{time_point::duration{valel.via.array.ptr[0].as<time_point::duration::rep>()}}; tmp_val.msgpack_unpack(valel.via.array.ptr[1]); } catch (const std::exception&) { - DHT_LOG.ERROR("Error reading value at %s", h.first.toString().c_str()); + DHT_LOG.ERR("Error reading value at %s", h.first.toString().c_str()); continue; } if (val_time + getType(tmp_val.type).expiration < scheduler.time()) { @@ -2377,7 +2377,7 @@ Dht::importValues(const std::vector<ValuesExport>& import) storageStore(h.first, std::make_shared<Value>(std::move(tmp_val)), val_time); } } catch (const std::exception&) { - DHT_LOG.ERROR("Error reading values at %s", h.first.toString().c_str()); + DHT_LOG.ERR("Error reading values at %s", h.first.toString().c_str()); continue; } } diff --git a/src/network_engine.cpp b/src/network_engine.cpp index 56a05472e317276404a0255802359c042c31549e..e24a1ddfd7d4e667be7fa6930384170c6a9acb0f 100644 --- a/src/network_engine.cpp +++ b/src/network_engine.cpp @@ -92,7 +92,7 @@ NetworkEngine::tellListener(std::shared_ptr<Node> node, uint16_t rid, InfoHash h sendNodesValues((const sockaddr*)&node->ss, node->sslen, TransId {TransPrefix::GET_VALUES, (uint16_t)rid}, nnodes.first, nnodes.second, values, ntoken); } catch (const std::overflow_error& e) { - DHT_LOG.ERROR("Can't send value: buffer not large enough !"); + DHT_LOG.ERR("Can't send value: buffer not large enough !"); } } @@ -145,7 +145,7 @@ NetworkEngine::requestStep(std::shared_ptr<Request> req) auto now = scheduler.time(); if (req->isExpired(now)) { - DHT_LOG.ERROR("[node %s] expired !", req->node->toString().c_str()); + DHT_LOG.ERR("[node %s] expired !", req->node->toString().c_str()); req->node->setExpired(); requests.erase(req->tid); return; @@ -176,7 +176,7 @@ NetworkEngine::sendRequest(std::shared_ptr<Request>& request) request->start = scheduler.time(); auto e = requests.emplace(request->tid, request); if (!e.second) { - DHT_LOG.ERROR("Request already existed !"); + DHT_LOG.ERR("Request already existed !"); } request->node->requested(request); requestStep(request); @@ -309,8 +309,8 @@ NetworkEngine::processMessage(const uint8_t *buf, size_t buflen, const sockaddr* const auto& now = scheduler.time(); if (msg.tid.length != 4) { - DHT_LOG.ERROR("Broken node truncates transaction ids (len: %d): ", msg.tid.length); - DHT_LOG.ERROR.logPrintable(buf, buflen); + DHT_LOG.ERR("Broken node truncates transaction ids (len: %d): ", msg.tid.length); + DHT_LOG.ERR.logPrintable(buf, buflen); blacklistNode(cache.getNode(msg.id, from, fromlen, now, 1)); return; } @@ -436,7 +436,7 @@ NetworkEngine::processMessage(const uint8_t *buf, size_t buflen, const sockaddr* break; } } catch (const std::overflow_error& e) { - DHT_LOG.ERROR("Can't send value: buffer not large enough !"); + DHT_LOG.ERR("Can't send value: buffer not large enough !"); } catch (DhtProtocolException& e) { sendError(from, fromlen, msg.tid, e.getCode(), e.getMsg().c_str(), true); } diff --git a/src/securedht.cpp b/src/securedht.cpp index 8ca9ac9663fd8548aea96e80a65a81819a2400d1..93098f2a8e6b72082776805ab0277a4c01560ed2 100644 --- a/src/securedht.cpp +++ b/src/securedht.cpp @@ -77,7 +77,7 @@ SecureDht::SecureDht(int s, int s6, SecureDht::Config conf) if (ok) DHT_LOG.DEBUG("SecureDht: public key announced successfully"); else - DHT_LOG.ERROR("SecureDht: error while announcing public key!"); + DHT_LOG.ERR("SecureDht: error while announcing public key!"); }); } } @@ -323,9 +323,9 @@ SecureDht::putSigned(const InfoHash& hash, std::shared_ptr<Value> val, DoneCallb DHT_LOG.DEBUG("Found online previous value being announced."); for (const auto& v : vals) { if (!v->isSigned()) - DHT_LOG.ERROR("Existing non-signed value seems to exists at this location."); + DHT_LOG.ERR("Existing non-signed value seems to exists at this location."); else if (not v->owner or v->owner->getId() != getId()) - DHT_LOG.ERROR("Existing signed value belonging to someone else seems to exists at this location."); + DHT_LOG.ERR("Existing signed value belonging to someone else seems to exists at this location."); else if (val->seq <= v->seq) val->seq = v->seq + 1; } @@ -352,7 +352,7 @@ SecureDht::putEncrypted(const InfoHash& hash, const InfoHash& to, std::shared_pt try { put(hash, encrypt(*val, *pk), callback); } catch (const std::exception& e) { - DHT_LOG.ERROR("Error putting encrypted data: %s", e.what()); + DHT_LOG.ERR("Error putting encrypted data: %s", e.what()); if (callback) callback(false, {}); }