From d0c7c5227d1f272c009eba96ac0b9fcb788b6d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Fri, 12 Feb 2021 13:25:42 -0500 Subject: [PATCH] log cleanup Change-Id: I139b6fcb70986be033c88bbf7e0545af326ff407 --- src/config/yamlparser.h | 2 +- src/im/message_engine.cpp | 10 ++++++---- src/jamidht/contact_list.cpp | 28 +++++++++++++++------------- src/jamidht/jamiaccount.cpp | 16 ++++++++-------- src/media/audio/ringbufferpool.cpp | 3 +-- src/sip/siptransport.cpp | 6 +----- src/sip/sipvoiplink.cpp | 2 +- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/config/yamlparser.h b/src/config/yamlparser.h index 9e2efe8301..9c66a6de39 100644 --- a/src/config/yamlparser.h +++ b/src/config/yamlparser.h @@ -44,7 +44,7 @@ parseValueOptional(const YAML::Node& node, const char* key, T& value) parseValue(node, key, value); return true; } catch (const std::exception& e) { - JAMI_DBG("Can't read yaml field: %s", key); + // JAMI_DBG("Can't read yaml field: %s", key); } return false; } diff --git a/src/im/message_engine.cpp b/src/im/message_engine.cpp index 568051ae71..97ac49bd16 100644 --- a/src/im/message_engine.cpp +++ b/src/im/message_engine.cpp @@ -227,10 +227,12 @@ MessageEngine::load() loaded++; } } - JAMI_DBG("[Account %s] loaded %lu messages from %s", - account_.getAccountID().c_str(), - loaded, - savePath_.c_str()); + if (loaded > 0) { + JAMI_DBG("[Account %s] loaded %lu messages from %s", + account_.getAccountID().c_str(), + loaded, + savePath_.c_str()); + } } catch (const std::exception& e) { JAMI_DBG("[Account %s] couldn't load messages from %s: %s", account_.getAccountID().c_str(), diff --git a/src/jamidht/contact_list.cpp b/src/jamidht/contact_list.cpp index bb4b4ec8fc..7dd66f81ad 100644 --- a/src/jamidht/contact_list.cpp +++ b/src/jamidht/contact_list.cpp @@ -163,7 +163,7 @@ ContactList::updateContact(const dht::InfoHash& id, const Contact& contact) bool stateChanged {false}; auto c = contacts_.find(id); if (c == contacts_.end()) { - JAMI_DBG("[Contacts] new contact: %s", id.toString().c_str()); + // JAMI_DBG("[Contacts] new contact: %s", id.toString().c_str()); c = contacts_.emplace(id, contact).first; stateChanged = c->second.isActive() or c->second.isBanned(); } else { @@ -355,9 +355,9 @@ ContactList::loadKnownDevices() } for (const auto& d : knownDevices) { - JAMI_DBG("[Contacts] loading known account device %s %s", + /*JAMI_DBG("[Contacts] loading known account device %s %s", d.second.first.c_str(), - d.first.toString().c_str()); + d.first.toString().c_str());*/ if (auto crt = tls::CertificateStore::instance().getCertificate(d.first.toString())) { if (not foundAccountDevice(crt, d.second.first, clock::from_time_t(d.second.second))) JAMI_WARN("[Contacts] can't add device %s", d.first.toString().c_str()); @@ -413,35 +413,37 @@ ContactList::foundAccountDevice(const std::shared_ptr<dht::crypto::Certificate>& if (not crt) return false; + auto id = crt->getId(); + // match certificate chain auto verifyResult = accountTrust_.verify(*crt); if (not verifyResult) { JAMI_WARN("[Contacts] Found invalid account device: %s: %s", - crt->getId().toString().c_str(), + id.toString().c_str(), verifyResult.toString().c_str()); return false; } // insert device - auto it = knownDevices_.emplace(crt->getId(), KnownDevice {crt, name, updated}); + auto it = knownDevices_.emplace(id, KnownDevice {crt, name, updated}); if (it.second) { JAMI_DBG("[Contacts] Found account device: %s %s", name.c_str(), - crt->getId().toString().c_str()); + id.toString().c_str()); tls::CertificateStore::instance().pinCertificate(crt); if (crt->ocspResponse) { unsigned int status = crt->ocspResponse->getCertificateStatus(); if (status == GNUTLS_OCSP_CERT_GOOD) { - JAMI_DBG("Certificate %s has good OCSP status", crt->getId().to_c_str()); - trust_.setCertificateStatus(crt->getId().toString(), + JAMI_DBG("Certificate %s has good OCSP status", id.to_c_str()); + trust_.setCertificateStatus(id.toString(), tls::TrustStore::PermissionStatus::ALLOWED); } else if (status == GNUTLS_OCSP_CERT_REVOKED) { - JAMI_ERR("Certificate %s has revoked OCSP status", crt->getId().to_c_str()); - trust_.setCertificateStatus(crt->getId().toString(), + JAMI_ERR("Certificate %s has revoked OCSP status", id.to_c_str()); + trust_.setCertificateStatus(id.toString(), tls::TrustStore::PermissionStatus::BANNED); } else { - JAMI_ERR("Certificate %s has unknown OCSP status", crt->getId().to_c_str()); - trust_.setCertificateStatus(crt->getId().toString(), + JAMI_ERR("Certificate %s has unknown OCSP status", id.to_c_str()); + trust_.setCertificateStatus(id.toString(), tls::TrustStore::PermissionStatus::UNDEFINED); } } @@ -452,7 +454,7 @@ ContactList::foundAccountDevice(const std::shared_ptr<dht::crypto::Certificate>& if (not name.empty() and it.first->second.name != name) { JAMI_DBG("[Contacts] updating device name: %s %s", name.c_str(), - crt->getId().toString().c_str()); + id.to_c_str()); it.first->second.name = name; saveKnownDevices(); callbacks_.devicesChanged(knownDevices_); diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 89c7fd6051..d9748e5eed 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -313,7 +313,7 @@ JamiAccount::JamiAccount(const std::string& accountID, bool /* presenceEnabled * std::chrono::hours(24 * 7))); std::getline(is, proxyServerCached_); } catch (const std::exception& e) { - JAMI_DBG("Can't load proxy URL from cache: %s", e.what()); + JAMI_DBG("[Account %s] Can't load proxy URL from cache: %s", getAccountID().c_str(), e.what()); } setActiveCodecs({}); @@ -1960,7 +1960,7 @@ JamiAccount::loadBootstrap() const while (std::getline(ss, node_addr, ';')) bootstrap.emplace_back(std::move(node_addr)); for (const auto& b : bootstrap) - JAMI_DBG("Bootstrap node: %s", b.c_str()); + JAMI_DBG("[Account %s] Bootstrap node: %s", getAccountID().c_str(), b.c_str()); } return bootstrap; } @@ -3578,7 +3578,7 @@ JamiAccount::cacheTurnServers() this_->isRefreshing_ = false; return; } - JAMI_INFO("Refresh cache for TURN server resolution"); + JAMI_INFO("[Account %s] Refresh cache for TURN server resolution", this_->getAccountID().c_str()); // Retrieve old cached value if available. // This means that we directly get the correct value when launching the application on the // same network @@ -3628,7 +3628,7 @@ JamiAccount::cacheTurnServers() this_->cacheTurnV6_ = std::make_unique<IpAddr>(std::move(turnV6)); } this_->isRefreshing_ = false; - JAMI_INFO("Cache refreshed for TURN resolution"); + JAMI_INFO("[Account %s] Cache refreshed for TURN resolution", this_->getAccountID().c_str()); }); } @@ -3662,12 +3662,12 @@ JamiAccount::requestSIPConnection(const std::string& peerId, const DeviceId& dev auto id = std::make_pair(peerId, deviceId); if (sipConns_.find(id) != sipConns_.end()) { - JAMI_DBG("A SIP connection with %s already exists", deviceId.to_c_str()); + JAMI_DBG("[Account %s] A SIP connection with %s already exists", getAccountID().c_str(), deviceId.to_c_str()); return; } sipConns_[id] = {}; // If not present, create it - JAMI_INFO("Ask %s for a new SIP channel", deviceId.to_c_str()); + JAMI_INFO("[Account %s] Ask %s for a new SIP channel", getAccountID().c_str(), deviceId.to_c_str()); if (!connectionManager_) return; connectionManager_->connectDevice(deviceId, @@ -3855,7 +3855,7 @@ JamiAccount::cacheSIPConnection(std::shared_ptr<ChannelSocket>&& socket, return v.channel == socket; }); if (conn != connections.end()) { - JAMI_WARN("Channel socket already cached with this peer"); + JAMI_WARN("[Account %s] Channel socket already cached with this peer", getAccountID().c_str()); return; } @@ -3890,7 +3890,7 @@ JamiAccount::cacheSIPConnection(std::shared_ptr<ChannelSocket>&& socket, sip_tr->setAccount(shared()); // Store the connection connections.emplace_back(SipConnection {sip_tr, socket}); - JAMI_WARN("New SIP channel opened with %s", deviceId.to_c_str()); + JAMI_WARN("[Account %s] New SIP channel opened with %s", getAccountID().c_str(), deviceId.to_c_str()); lk.unlock(); sendProfile(deviceId.toString()); diff --git a/src/media/audio/ringbufferpool.cpp b/src/media/audio/ringbufferpool.cpp index 49b9809d91..147767d3ca 100644 --- a/src/media/audio/ringbufferpool.cpp +++ b/src/media/audio/ringbufferpool.cpp @@ -115,8 +115,7 @@ RingBufferPool::createRingBuffer(const std::string& id) } rbuf.reset(new RingBuffer(id, SIZEBUF, internalAudioFormat_)); - JAMI_DBG("Ringbuffer created with id '%s'", id.c_str()); - ringBufferMap_.insert(std::make_pair(id, std::weak_ptr<RingBuffer>(rbuf))); + ringBufferMap_.emplace(id, std::weak_ptr<RingBuffer>(rbuf)); return rbuf; } diff --git a/src/sip/siptransport.cpp b/src/sip/siptransport.cpp index 2ddf54040b..b4943392f4 100644 --- a/src/sip/siptransport.cpp +++ b/src/sip/siptransport.cpp @@ -187,14 +187,10 @@ SipTransport::getTlsMtu() SipTransportBroker::SipTransportBroker(pjsip_endpoint* endpt) : endpt_(endpt) -{ - JAMI_DBG("SipTransportBroker@%p", this); -} +{} SipTransportBroker::~SipTransportBroker() { - JAMI_DBG("~SipTransportBroker@%p", this); - shutdown(); udpTransports_.clear(); diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index 7c3a854197..25132634f5 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -647,7 +647,7 @@ SIPVoIPLink::SIPVoIPLink() TRY(pjsip_100rel_init_module(endpt_)); // Initialize and register ring module - mod_ua_.name = pj_str((char*) PACKAGE); + mod_ua_.name = sip_utils::CONST_PJ_STR(PACKAGE); mod_ua_.id = -1; mod_ua_.priority = PJSIP_MOD_PRIORITY_APPLICATION; mod_ua_.on_rx_request = &transaction_request_cb; -- GitLab