ipc/chromium/src/base/logging.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright (c) 2006-2009 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.
     5 #include "base/logging.h"
     6 #include "prmem.h"
     7 #include "prprf.h"
     8 #include "base/string_util.h"
     9 #include "nsXPCOM.h"
    11 namespace mozilla {
    13 Logger::~Logger()
    14 {
    15   PRLogModuleLevel prlevel = PR_LOG_DEBUG;
    16   int xpcomlevel = -1;
    18   switch (mSeverity) {
    19   case LOG_INFO:
    20     prlevel = PR_LOG_DEBUG;
    21     xpcomlevel = -1;
    22     break;
    24   case LOG_WARNING:
    25     prlevel = PR_LOG_WARNING;
    26     xpcomlevel = NS_DEBUG_WARNING;
    27     break;
    29   case LOG_ERROR:
    30     prlevel = PR_LOG_ERROR;
    31     xpcomlevel = NS_DEBUG_WARNING;
    32     break;
    34   case LOG_ERROR_REPORT:
    35     prlevel = PR_LOG_ERROR;
    36     xpcomlevel = NS_DEBUG_ASSERTION;
    37     break;
    39   case LOG_FATAL:
    40     prlevel = PR_LOG_ERROR;
    41     xpcomlevel = NS_DEBUG_ABORT;
    42     break;
    43   }
    45   PR_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
    46   if (xpcomlevel != -1)
    47     NS_DebugBreak(xpcomlevel, mMsg, NULL, mFile, mLine);
    49   PR_Free(mMsg);
    50 }
    52 void
    53 Logger::printf(const char* fmt, ...)
    54 {
    55   va_list args;
    56   va_start(args, fmt);
    57   mMsg = PR_vsprintf_append(mMsg, fmt, args);
    58   va_end(args);
    59 }
    61 PRLogModuleInfo* Logger::gChromiumPRLog;
    63 PRLogModuleInfo* Logger::GetLog()
    64 {
    65   if (!gChromiumPRLog)
    66     gChromiumPRLog = PR_NewLogModule("chromium");
    67   return gChromiumPRLog;
    68 }
    70 } // namespace mozilla 
    72 mozilla::Logger&
    73 operator<<(mozilla::Logger& log, const char* s)
    74 {
    75   log.printf("%s", s);
    76   return log;
    77 }
    79 mozilla::Logger&
    80 operator<<(mozilla::Logger& log, const std::string& s)
    81 {
    82   log.printf("%s", s.c_str());
    83   return log;
    84 }
    86 mozilla::Logger&
    87 operator<<(mozilla::Logger& log, int i)
    88 {
    89   log.printf("%i", i);
    90   return log;
    91 }
    93 mozilla::Logger&
    94 operator<<(mozilla::Logger& log, const std::wstring& s)
    95 {
    96   log.printf("%s", WideToASCII(s).c_str());
    97   return log;
    98 }
   100 mozilla::Logger&
   101 operator<<(mozilla::Logger& log, void* p)
   102 {
   103   log.printf("%p", p);
   104   return log;
   105 }

mercurial