1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/common/media/webrtc_logging_message_data.h"
6
7#include "base/strings/stringprintf.h"
8
9WebRtcLoggingMessageData::WebRtcLoggingMessageData() {}
10
11WebRtcLoggingMessageData::WebRtcLoggingMessageData(base::Time time,
12                                                   const std::string& message)
13    : timestamp(time), message(message) {}
14
15std::string
16WebRtcLoggingMessageData::Format(base::Time start_time) const {
17  int32 interval_ms =
18      static_cast<int32>((timestamp - start_time).InMilliseconds());
19
20  std::string result = base::StringPrintf("[%03d:%03d] %s",
21                                          interval_ms / 1000,
22                                          interval_ms % 1000,
23                                          message.c_str());
24  return result;
25}
26