Open Bug 2044817 Opened 5 months ago Updated 1 month ago

`dom/media/webrtc`: use fmt format_as/operator<< instead of explicit log conversions

Categories

(Core :: WebRTC, task)

task

Tracking

()

ASSIGNED

People

(Reporter: alwu, Assigned: calvincramer)

References

Details

(Keywords: good-first-bug)

Attachments

(5 external files)

Follow-up to Bug 2044124, which migrated dom/media logging to MOZ_LOG_FMT.

During review of D304270 (Part 19), reviewers (bwc, pehrsons) noted several remaining dom/media/webrtc log call sites that still perform explicit string conversions that {fmt} could handle automatically via format_as free functions or operator<< overloads. Converting these sites removes per-call-site boilerplate and may also provide a small binary-size benefit.

Concrete examples identified during review:

  • dom/media/webrtc/MediaEngineRemoteVideoSource.cpp

    • LOG("ChooseCapability({})...", ToString(distanceMode))
    • Add a format_as implementation for the distance-mode type so it can be logged directly as:
      LOG("ChooseCapability({})...", distanceMode).
    • ErrorNames.h's format_as(nsresult) provides a useful reference pattern.
  • dom/media/webrtc/MediaEngineRemoteVideoSource.cpp

    • LogCapability(...) logs ConvertVideoTypeToCStr(aCapability.videoType).
    • Add a format_as implementation for the video-type enum and log the enum directly.
  • dom/media/webrtc/MediaEngineWebRTC.cpp

    • EnumerateMicrophoneDevices logs NS_ConvertUTF16toUTF8(deviceInfo->Name()).get().
    • Log the nsString directly using the existing string formatter / operator<< support.
  • As noted by bwc, there are likely "lots of similar places scattered around" dom/media.

    • Opportunistically convert additional cases while touching this area.

This is a behavior-preserving logging cleanup only. No new tests are required; a successful build is sufficient validation.

I'm spending some time on this. I don't think I can assign myself, but please do if you can @alwu

Assignee: nobody → calvincramer
Status: NEW → ASSIGNED

Added 5 changes just to start the process. There's still lots more places to review in webrtc

Not sure if these multiple small commits with one diff each is best for review process. What's the standard here?

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: