LCOV - code coverage report
Current view: top level - image - ImageLogging.h (source / functions) Hit Total Coverage
Test: output.info Lines: 39 39 100.0 %
Date: 2017-07-14 16:53:18 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  *
       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             : #ifndef mozilla_image_ImageLogging_h
       8             : #define mozilla_image_ImageLogging_h
       9             : 
      10             : #include "mozilla/Logging.h"
      11             : #include "prinrval.h"
      12             : 
      13             : static mozilla::LazyLogModule gImgLog("imgRequest");
      14             : 
      15             : #define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
      16             : 
      17             : using mozilla::LogLevel;
      18             : 
      19             : class LogScope {
      20             : public:
      21             : 
      22         216 :   LogScope(mozilla::LogModule* aLog, void* aFrom, const char* aFunc)
      23         216 :     : mLog(aLog)
      24             :     , mFrom(aFrom)
      25         216 :     , mFunc(aFunc)
      26             :   {
      27         216 :     MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {ENTER}\n",
      28             :                                 GIVE_ME_MS_NOW(), mFrom, mFunc));
      29         216 :   }
      30             : 
      31             :   /* const char * constructor */
      32         141 :   LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
      33             :            const char* paramName, const char* paramValue)
      34         141 :     : mLog(aLog)
      35             :     , mFrom(from)
      36         141 :     , mFunc(fn)
      37             :   {
      38         141 :     MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\") {ENTER}\n",
      39             :                                  GIVE_ME_MS_NOW(), mFrom, mFunc,
      40             :                                  paramName, paramValue));
      41         141 :   }
      42             : 
      43             :   /* void ptr constructor */
      44         377 :   LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
      45             :            const char* paramName, const void* paramValue)
      46         377 :     : mLog(aLog)
      47             :     , mFrom(from)
      48         377 :     , mFunc(fn)
      49             :   {
      50         377 :     MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=%p) {ENTER}\n",
      51             :                                 GIVE_ME_MS_NOW(), mFrom, mFunc,
      52             :                                 paramName, paramValue));
      53         377 :   }
      54             : 
      55             :   /* int32_t constructor */
      56             :   LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
      57             :            const char* paramName, int32_t paramValue)
      58             :     : mLog(aLog)
      59             :     , mFrom(from)
      60             :     , mFunc(fn)
      61             :   {
      62             :     MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
      63             :                                 GIVE_ME_MS_NOW(), mFrom, mFunc,
      64             :                                 paramName, paramValue));
      65             :   }
      66             : 
      67             :   /* uint32_t constructor */
      68          41 :   LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
      69             :            const char* paramName, uint32_t paramValue)
      70          41 :     : mLog(aLog)
      71             :     , mFrom(from)
      72          41 :     , mFunc(fn)
      73             :   {
      74          41 :     MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
      75             :                                 GIVE_ME_MS_NOW(), mFrom, mFunc,
      76             :                                 paramName, paramValue));
      77          41 :   }
      78             : 
      79         775 :   ~LogScope()
      80         775 :   {
      81         775 :     MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {EXIT}\n",
      82             :                                 GIVE_ME_MS_NOW(), mFrom, mFunc));
      83         775 :   }
      84             : 
      85             : private:
      86             :   mozilla::LogModule* mLog;
      87             :   void* mFrom;
      88             :   const char* mFunc;
      89             : };
      90             : 
      91             : class LogFunc {
      92             : public:
      93         133 :   LogFunc(mozilla::LogModule* aLog, void* from, const char* fn)
      94             :   {
      95         133 :     MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s\n",
      96             :                                 GIVE_ME_MS_NOW(), from, fn));
      97         133 :   }
      98             : 
      99         803 :   LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
     100             :           const char* paramName, const char* paramValue)
     101             :   {
     102         803 :     MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\")\n",
     103             :                                 GIVE_ME_MS_NOW(), from, fn,
     104             :                                 paramName, paramValue));
     105         803 :   }
     106             : 
     107           4 :   LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
     108             :           const char* paramName, const void* paramValue)
     109             :   {
     110           4 :     MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%p\")\n",
     111             :                                 GIVE_ME_MS_NOW(), from, fn,
     112             :                                 paramName, paramValue));
     113           4 :   }
     114             : 
     115             : 
     116          42 :   LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
     117             :           const char* paramName, uint32_t paramValue)
     118             :   {
     119          42 :     MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\")\n",
     120             :                                 GIVE_ME_MS_NOW(), from, fn,
     121             :                                 paramName, paramValue));
     122          42 :   }
     123             : 
     124             : };
     125             : 
     126             : 
     127             : class LogMessage {
     128             : public:
     129          45 :   LogMessage(mozilla::LogModule* aLog, void* from, const char* fn,
     130             :              const char* msg)
     131             :   {
     132          45 :     MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s -- %s\n",
     133             :                                 GIVE_ME_MS_NOW(), from, fn, msg));
     134          45 :   }
     135             : };
     136             : 
     137             : #define LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
     138             : #define LOG_SCOPE_APPEND_LINE_NUMBER_EXPAND(id, line) \
     139             :         LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line)
     140             : #define LOG_SCOPE_APPEND_LINE_NUMBER(id) \
     141             :         LOG_SCOPE_APPEND_LINE_NUMBER_EXPAND(id, __LINE__)
     142             : 
     143             : #define LOG_SCOPE(l, s) \
     144             :   LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l, this, s)
     145             : 
     146             : #define LOG_SCOPE_WITH_PARAM(l, s, pn, pv) \
     147             :   LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l, this, s, pn, pv)
     148             : 
     149             : #define LOG_FUNC(l, s) LogFunc(l, this, s)
     150             : 
     151             : #define LOG_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, this, s, pn, pv)
     152             : 
     153             : #define LOG_STATIC_FUNC(l, s) LogFunc(l, nullptr, s)
     154             : 
     155             : #define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, nullptr, s, pn, pv)
     156             : 
     157             : #define LOG_MSG(l, s, m) LogMessage(l, this, s, m)
     158             : 
     159             : #define LOG_MSG_WITH_PARAM LOG_FUNC_WITH_PARAM
     160             : 
     161             : #endif // mozilla_image_ImageLogging_h

Generated by: LCOV version 1.13