Commit cdeb2805 authored by servolk's avatar servolk Committed by Commit bot

Add media log messages to the main log

Currently media code uses a separate logging system (MediaLog) and some important messages are reported there, but are not reported in the main browser log. Currently media log messages can only be seen in the chrome://media-internals, but since they are very useful, we should add them to the main browser log as well.

BUG=453180

Review URL: https://codereview.chromium.org/877273002

Cr-Commit-Position: refs/heads/master@{#322425}
parent fb77ecc7
...@@ -27,6 +27,16 @@ void RenderMediaLog::AddEvent(scoped_ptr<media::MediaLogEvent> event) { ...@@ -27,6 +27,16 @@ void RenderMediaLog::AddEvent(scoped_ptr<media::MediaLogEvent> event) {
return; return;
} }
if (event->type == media::MediaLogEvent::PIPELINE_ERROR) {
LOG(ERROR) << "MediaEvent: "
<< media::MediaLog::MediaEventToLogString(*event.get());
} else if (event->type != media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED &&
event->type != media::MediaLogEvent::PROPERTY_CHANGE &&
event->type != media::MediaLogEvent::NETWORK_ACTIVITY_SET) {
DVLOG(1) << "MediaEvent: "
<< media::MediaLog::MediaEventToLogString(*event.get());
}
// Keep track of the latest buffered extents properties to avoid sending // Keep track of the latest buffered extents properties to avoid sending
// thousands of events over IPC. See http://crbug.com/352585 for details. // thousands of events over IPC. See http://crbug.com/352585 for details.
// //
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string> #include <string>
#include "base/atomic_sequence_num.h" #include "base/atomic_sequence_num.h"
#include "base/json/json_writer.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/values.h" #include "base/values.h"
...@@ -98,6 +99,22 @@ std::string MediaLog::PipelineStatusToString(PipelineStatus status) { ...@@ -98,6 +99,22 @@ std::string MediaLog::PipelineStatusToString(PipelineStatus status) {
return NULL; return NULL;
} }
std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event) {
// Special case for PIPELINE_ERROR, since that's by far the most useful
// event for figuring out media pipeline failures, and just reporting
// pipeline status as numeric code is not very helpful/user-friendly.
int error_code = 0;
if (event.type == MediaLogEvent::PIPELINE_ERROR &&
event.params.GetInteger("pipeline_error", &error_code)) {
PipelineStatus status = static_cast<PipelineStatus>(error_code);
return EventTypeToString(event.type) + " " +
media::MediaLog::PipelineStatusToString(status);
}
std::string params_json;
base::JSONWriter::Write(&event.params, &params_json);
return EventTypeToString(event.type) + " " + params_json;
}
LogHelper::LogHelper(const LogCB& log_cb) : log_cb_(log_cb) {} LogHelper::LogHelper(const LogCB& log_cb) : log_cb_(log_cb) {}
LogHelper::~LogHelper() { LogHelper::~LogHelper() {
......
...@@ -48,6 +48,8 @@ class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> { ...@@ -48,6 +48,8 @@ class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> {
static std::string EventTypeToString(MediaLogEvent::Type type); static std::string EventTypeToString(MediaLogEvent::Type type);
static std::string PipelineStatusToString(PipelineStatus status); static std::string PipelineStatusToString(PipelineStatus status);
static std::string MediaEventToLogString(const MediaLogEvent& event);
MediaLog(); MediaLog();
// Add an event to this log. Overriden by inheritors to actually do something // Add an event to this log. Overriden by inheritors to actually do something
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment