1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/renderer/media/webrtc_logging.h" 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 7effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "base/time/time.h" 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/renderer/webrtc_log_message_delegate.h" 95f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "third_party/webrtc/overrides/webrtc/base/logging.h" 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content { 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Shall only be set once and never go back to NULL. 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL; 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) { 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CHECK(!g_webrtc_logging_delegate); 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CHECK(delegate); 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) g_webrtc_logging_delegate = delegate; 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)void InitWebRtcLogging() { 24c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Log messages from Libjingle should not have timestamps. 255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) rtc::InitDiagnosticLoggingDelegateFunction(&WebRtcLogMessage); 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void WebRtcLogMessage(const std::string& message) { 29c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch if (g_webrtc_logging_delegate) 30c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch g_webrtc_logging_delegate->LogMessage(message); 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace content 34