Improves logging in MediaChannel

This CL changes the style of logging for an API which is essential when
WebRTC is used in Chrome. By changing the format, we can more easily
tie in (search for tags etc.) logs from WebRTC with logs in Chrome.
See e.g.
https://chromium-review.googlesource.com/c/chromium/src/+/2093443
for more details.

I decided to use a new private method to avoid using rtc::StringBuilder.
The idea was to make the log statements less complex and more condensed.

Tbr: mbonadei
Bug: webrtc:11493
Change-Id: I46b4a933ad62ac1db376743b4a41b62c5f8c6ac6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172841
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31808}
This commit is contained in:
henrika 2020-07-29 17:20:13 +02:00 committed by Henrik Andreassson
parent 3ea3e0c345
commit c6cf902034
2 changed files with 12 additions and 4 deletions

View File

@ -11,7 +11,6 @@
#include "media/engine/webrtc_voice_engine.h" #include "media/engine/webrtc_voice_engine.h"
#include <algorithm> #include <algorithm>
#include <cstdio>
#include <functional> #include <functional>
#include <string> #include <string>
#include <utility> #include <utility>
@ -43,6 +42,7 @@
#include "rtc_base/race_checker.h" #include "rtc_base/race_checker.h"
#include "rtc_base/strings/audio_format_to_string.h" #include "rtc_base/strings/audio_format_to_string.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "rtc_base/strings/string_format.h"
#include "rtc_base/third_party/base64/base64.h" #include "rtc_base/third_party/base64/base64.h"
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"
#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/field_trial.h"
@ -2051,14 +2051,19 @@ bool WebRtcVoiceMediaChannel::SetLocalSource(uint32_t ssrc,
bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
RTC_DCHECK(worker_thread_checker_.IsCurrent()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << rtc::StringFormat("WRVMC::%s({ssrc=%u}, {volume=%.2f})",
__func__, ssrc, volume);
const auto it = recv_streams_.find(ssrc); const auto it = recv_streams_.find(ssrc);
if (it == recv_streams_.end()) { if (it == recv_streams_.end()) {
RTC_LOG(LS_WARNING) << "SetOutputVolume: no recv stream " << ssrc; RTC_LOG(LS_WARNING) << rtc::StringFormat(
"WRVMC::%s => (WARNING: no receive stream for SSRC %u)", __func__,
ssrc);
return false; return false;
} }
it->second->SetOutputVolume(volume); it->second->SetOutputVolume(volume);
RTC_LOG(LS_INFO) << "SetOutputVolume() to " << volume RTC_LOG(LS_INFO) << rtc::StringFormat(
<< " for recv stream with ssrc " << ssrc; "WRVMC::%s => (stream with SSRC %u now uses volume %.2f)", __func__, ssrc,
volume);
return true; return true;
} }

View File

@ -22,6 +22,7 @@
#include "rtc_base/location.h" #include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/strings/string_format.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "rtc_base/thread_checker.h" #include "rtc_base/thread_checker.h"
@ -102,6 +103,8 @@ bool RemoteAudioSource::remote() const {
void RemoteAudioSource::SetVolume(double volume) { void RemoteAudioSource::SetVolume(double volume) {
RTC_DCHECK_GE(volume, 0); RTC_DCHECK_GE(volume, 0);
RTC_DCHECK_LE(volume, 10); RTC_DCHECK_LE(volume, 10);
RTC_LOG(LS_INFO) << rtc::StringFormat("RAS::%s({volume=%.2f})", __func__,
volume);
for (auto* observer : audio_observers_) { for (auto* observer : audio_observers_) {
observer->OnSetVolume(volume); observer->OnSetVolume(volume);
} }