Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: content/renderer/media/webrtc_logging.cc

Issue 216693007: Adds timestamp to the log messages from Chrome in the webrtc native log. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_logging.cc
diff --git a/content/renderer/media/webrtc_logging.cc b/content/renderer/media/webrtc_logging.cc
index 2bdc7a33e5a5c5cd8c49c274059119029806b819..29cf5f50c9b1e6c1249e5662702c4f0c9c73d093 100644
--- a/content/renderer/media/webrtc_logging.cc
+++ b/content/renderer/media/webrtc_logging.cc
@@ -4,6 +4,10 @@
#include "content/renderer/media/webrtc_logging.h"
+#include <iomanip>
+#include <sstream>
+
+#include "base/time/time.h"
#include "content/public/renderer/webrtc_log_message_delegate.h"
#include "third_party/libjingle/overrides/talk/base/logging.h"
@@ -11,21 +15,44 @@ namespace content {
// Shall only be set once and never go back to NULL.
WebRtcLogMessageDelegate* g_webrtc_logging_delegate = NULL;
+uint64 g_started_time_ms_ = 0;
void InitWebRtcLoggingDelegate(WebRtcLogMessageDelegate* delegate) {
CHECK(!g_webrtc_logging_delegate);
CHECK(delegate);
g_webrtc_logging_delegate = delegate;
+
+ g_started_time_ms_ = base::Time::Now().ToInternalValue() /
+ base::Time::kMicrosecondsPerMillisecond;
+}
+
+void WebRtcLogMessageWithTimestamp(const std::string& message) {
+ if (g_webrtc_logging_delegate)
+ g_webrtc_logging_delegate->LogMessage(message);
}
void InitWebRtcLogging() {
- talk_base::InitDiagnosticLoggingDelegateFunction(WebRtcLogMessage);
+ // Log messages from Libjingle should always have timestamps.
+ talk_base::InitDiagnosticLoggingDelegateFunction(
+ WebRtcLogMessageWithTimestamp);
}
void WebRtcLogMessage(const std::string& message) {
- if (g_webrtc_logging_delegate)
- g_webrtc_logging_delegate->LogMessage(message);
+ // Keep consistent with talk_base::DiagnosticLogMessage::CreateTimestamp.
+ // TODO(grunell): remove the duplicated code and unify the timestamp creation.
+ uint64 now_us = base::Time::Now().ToInternalValue();
+ uint64 interval_ms = now_us / base::Time::kMicrosecondsPerMillisecond -
+ g_started_time_ms_;
+
+ std::ostringstream message_oss;
+ message_oss << "[" << std::setfill('0') << std::setw(3)
+ << (interval_ms / 1000)
+ << ":" << std::setw(3)
+ << (interval_ms % 1000)
+ << std::setfill(' ') << "] " << message;
+
+ WebRtcLogMessageWithTimestamp(message_oss.str());
}
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698