⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242886 in webkit


Ignore:
Timestamp:
Mar 13, 2019, 10:14:18 AM (7 years ago)
Author:
youenn@apple.com
Message:

Enable libwebrtc logging control through WebCore
https://bugs.webkit.org/show_bug.cgi?id=195658

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Add a callback to get access to libwebrtc log messages.

  • Configurations/libwebrtc.iOS.exp:
  • Configurations/libwebrtc.iOSsim.exp:
  • Configurations/libwebrtc.mac.exp:
  • Source/webrtc/rtc_base/logging.cc:
  • Source/webrtc/rtc_base/logging.h:

Source/WebCore:

Add support for WebCore logging of libwebrtc messages.
This is controlled by WebRTC log channel state and level.
In case of private browsing mode, any logging is disabled.
This will stay for the lifetime of the process.
No change of behavior.

  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::create):

  • platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:

(WebCore::doReleaseLogging):
(WebCore::setLogging):
(WebCore::computeLogLevel):
(WebCore::initializePeerConnectionFactoryAndThreads):
(WebCore::LibWebRTCProvider::setEnableLogging):

  • platform/mediastream/libwebrtc/LibWebRTCProvider.h:
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r242623 r242886  
     12019-03-13  Youenn Fablet  <youenn@apple.com>
     2
     3        Enable libwebrtc logging control through WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=195658
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add a callback to get access to libwebrtc log messages.
     9
     10        * Configurations/libwebrtc.iOS.exp:
     11        * Configurations/libwebrtc.iOSsim.exp:
     12        * Configurations/libwebrtc.mac.exp:
     13        * Source/webrtc/rtc_base/logging.cc:
     14        * Source/webrtc/rtc_base/logging.h:
     15
    1162019-03-07  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp

    r239252 r242886  
    247247__ZN6webrtc16RtpRtxParametersC1ERKS0_
    248248__ZN6webrtc16RtpRtxParametersD1Ev
     249__ZN3rtc10LogMessage12SetLogOutputENS_15LoggingSeverityEPFvS1_PKcE
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp

    r239252 r242886  
    248248__ZN6webrtc16RtpRtxParametersC1ERKS0_
    249249__ZN6webrtc16RtpRtxParametersD1Ev
     250__ZN3rtc10LogMessage12SetLogOutputENS_15LoggingSeverityEPFvS1_PKcE
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp

    r239252 r242886  
    248248__ZN6webrtc16RtpRtxParametersC1ERKS0_
    249249__ZN6webrtc16RtpRtxParametersD1Ev
     250__ZN3rtc10LogMessage12SetLogOutputENS_15LoggingSeverityEPFvS1_PKcE
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/logging.cc

    r238967 r242886  
    5353static LoggingSeverity g_dbg_sev = LS_NONE;
    5454#endif
     55static LogMessage::LogOutputCallback g_log_output_callback = nullptr;
     56
    5557
    5658// Return the filename portion of the string (that following the last slash).
     
    268270  CritScope cs(&logCriticalScope());
    269271  UpdateMinLogSeverity();
     272}
     273
     274void LogMessage::SetLogOutput(LoggingSeverity min_sev, LogOutputCallback callback)
     275{
     276  g_dbg_sev = min_sev;
     277  CritScope cs(&logCriticalScope());
     278  UpdateMinLogSeverity();
     279  g_log_output_callback = callback;
    270280}
    271281
     
    457467#endif  // WEBRTC_ANDROID
    458468  if (log_to_stderr) {
     469    if (g_log_output_callback)
     470      g_log_output_callback(severity, str.c_str());
    459471    fprintf(stderr, "%s", str.c_str());
    460472    fflush(stderr);
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/rtc_base/logging.h

    r238967 r242886  
    431431  //  Debug: Debug console on Windows, otherwise stderr
    432432  static void LogToDebug(LoggingSeverity min_sev);
     433
     434  typedef void (*LogOutputCallback)(LoggingSeverity severity, const char*);
     435  static void SetLogOutput(LoggingSeverity min_sev, LogOutputCallback);
    433436  static LoggingSeverity GetLogToDebug();
    434437
  • trunk/Source/WebCore/ChangeLog

    r242883 r242886  
     12019-03-13  Youenn Fablet  <youenn@apple.com>
     2
     3        Enable libwebrtc logging control through WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=195658
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add support for WebCore logging of libwebrtc messages.
     9        This is controlled by WebRTC log channel state and level.
     10        In case of private browsing mode, any logging is disabled.
     11        This will stay for the lifetime of the process.
     12        No change of behavior.
     13
     14        * Modules/mediastream/RTCPeerConnection.cpp:
     15        (WebCore::RTCPeerConnection::create):
     16        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
     17        (WebCore::doReleaseLogging):
     18        (WebCore::setLogging):
     19        (WebCore::computeLogLevel):
     20        (WebCore::initializePeerConnectionFactoryAndThreads):
     21        (WebCore::LibWebRTCProvider::setEnableLogging):
     22        * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
     23
    1242019-03-13  Thibault Saunier  <tsaunier@igalia.com>
    225
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r242804 r242886  
    7171    if (!peerConnection->isClosed()) {
    7272        peerConnection->m_pendingActivity = peerConnection->makePendingActivity(peerConnection.get());
    73         if (auto* page = downcast<Document>(context).page())
     73        if (auto* page = downcast<Document>(context).page()) {
    7474            peerConnection->registerToController(page->rtcController());
     75            page->libWebRTCProvider().setEnableLogging(!context.sessionID().isEphemeral());
     76        }
    7577    }
    7678    return peerConnection;
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp

    r239427 r242886  
    121121};
    122122
    123 static void initializePeerConnectionFactoryAndThreads(PeerConnectionFactoryAndThreads& factoryAndThreads)
    124 {
    125     ASSERT(!factoryAndThreads.networkThread);
    126 
     123static void doReleaseLogging(rtc::LoggingSeverity severity, const char* message)
     124{
     125    if (severity == rtc::LS_ERROR)
     126        RELEASE_LOG_ERROR(WebRTC, "LibWebRTC error: %{public}s", message);
     127    else
     128        RELEASE_LOG(WebRTC, "LibWebRTC message: %{public}s", message);
     129}
     130
     131static void setLogging(rtc::LoggingSeverity level)
     132{
     133    rtc::LogMessage::SetLogOutput(level, (level == rtc::LS_NONE) ? nullptr : doReleaseLogging);
     134}
     135
     136static rtc::LoggingSeverity computeLogLevel()
     137{
    127138#if defined(NDEBUG)
    128139#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
    129     rtc::LogMessage::LogToDebug(LogWebRTC.state != WTFLogChannelOn ? rtc::LS_NONE : rtc::LS_INFO);
     140    if (LogWebRTC.state != WTFLogChannelOn)
     141        return rtc::LS_ERROR;
     142
     143    switch (LogWebRTC.level) {
     144    case WTFLogLevelAlways:
     145    case WTFLogLevelError:
     146        return rtc::LS_ERROR;
     147    case WTFLogLevelWarning:
     148        return rtc::LS_WARNING;
     149    case WTFLogLevelInfo:
     150        return rtc::LS_INFO;
     151    case WTFLogLevelDebug:
     152        return rtc::LS_VERBOSE;
     153    }
    130154#else
    131     rtc::LogMessage::LogToDebug(rtc::LS_NONE);
     155    return rtc::LS_NONE;
    132156#endif
    133157#else
    134     rtc::LogMessage::LogToDebug(LogWebRTC.state != WTFLogChannelOn ? rtc::LS_WARNING : rtc::LS_INFO);
     158    return (LogWebRTC.state != WTFLogChannelOn) ? rtc::LS_WARNING : rtc::LS_INFO;
    135159#endif
     160}
     161
     162static void initializePeerConnectionFactoryAndThreads(PeerConnectionFactoryAndThreads& factoryAndThreads)
     163{
     164    ASSERT(!factoryAndThreads.networkThread);
    136165
    137166    factoryAndThreads.networkThread = factoryAndThreads.networkThreadWithSocketServer ? rtc::Thread::CreateWithSocketServer() : rtc::Thread::Create();
     
    193222    PeerConnectionFactoryAndThreads& threads = staticFactoryAndThreads();
    194223    threads.signalingThread->Post(RTC_FROM_HERE, &threads, 1, new ThreadMessageData(WTFMove(callback)));
     224}
     225
     226void LibWebRTCProvider::setEnableLogging(bool enableLogging)
     227{
     228    if (!m_enableLogging)
     229        return;
     230    m_enableLogging = enableLogging;
     231    setLogging(enableLogging ? computeLogLevel() : rtc::LS_NONE);
    195232}
    196233
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h

    r241200 r242886  
    116116    void clearFactory() { m_factory = nullptr; }
    117117
     118    void setEnableLogging(bool);
     119
    118120protected:
    119121    LibWebRTCProvider() = default;
     
    132134    bool m_disableNonLocalhostConnections { false };
    133135    bool m_supportsVP8 { false };
     136    bool m_enableLogging { true };
    134137#endif
    135138};
Note: See TracChangeset for help on using the changeset viewer.