tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DDLogMessage.cpp (1396B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "DDLogMessage.h"
      8 
      9 #include "DDLifetimes.h"
     10 
     11 namespace mozilla {
     12 
     13 nsCString DDLogMessage::Print() const {
     14  nsCString str;
     15  str.AppendPrintf("%" PRImi " | %f | %s[%p] | %s | %s | ", mIndex.Value(),
     16                   ToSeconds(mTimeStamp), mObject.TypeName(), mObject.Pointer(),
     17                   ToShortString(mCategory), mLabel);
     18  AppendToString(mValue, str);
     19  return str;
     20 }
     21 
     22 nsCString DDLogMessage::Print(const DDLifetimes& aLifetimes) const {
     23  nsCString str;
     24  const DDLifetime* lifetime = aLifetimes.FindLifetime(mObject, mIndex);
     25  str.AppendPrintf("%" PRImi " | %f | ", mIndex.Value(), ToSeconds(mTimeStamp));
     26  lifetime->AppendPrintf(str);
     27  str.AppendPrintf(" | %s | %s | ", ToShortString(mCategory), mLabel);
     28  if (!mValue.is<DDLogObject>()) {
     29    AppendToString(mValue, str);
     30  } else {
     31    const DDLifetime* lifetime2 =
     32        aLifetimes.FindLifetime(mValue.as<DDLogObject>(), mIndex);
     33    if (lifetime2) {
     34      lifetime2->AppendPrintf(str);
     35    } else {
     36      AppendToString(mValue, str);
     37    }
     38  }
     39  return str;
     40 }
     41 
     42 }  // namespace mozilla