Bug 1457047 [wpt PR 10645] - Update webidl2.js to v10.2.1, a=testonly
[gecko.git] / image / ImageLogging.h
blob4e4a4b9c5572d02bf7d385105ad7268347fd6006
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #ifndef mozilla_image_ImageLogging_h
8 #define mozilla_image_ImageLogging_h
10 #include "mozilla/Logging.h"
11 #include "prinrval.h"
13 static mozilla::LazyLogModule gImgLog("imgRequest");
15 #define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
17 using mozilla::LogLevel;
19 class LogScope {
20 public:
22 LogScope(mozilla::LogModule* aLog, void* aFrom, const char* aFunc)
23 : mLog(aLog)
24 , mFrom(aFrom)
25 , mFunc(aFunc)
27 MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {ENTER}\n",
28 GIVE_ME_MS_NOW(), mFrom, mFunc));
31 /* const char * constructor */
32 LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
33 const char* paramName, const char* paramValue)
34 : mLog(aLog)
35 , mFrom(from)
36 , mFunc(fn)
38 MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\") {ENTER}\n",
39 GIVE_ME_MS_NOW(), mFrom, mFunc,
40 paramName, paramValue));
43 /* void ptr constructor */
44 LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
45 const char* paramName, const void* paramValue)
46 : mLog(aLog)
47 , mFrom(from)
48 , mFunc(fn)
50 MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=%p) {ENTER}\n",
51 GIVE_ME_MS_NOW(), mFrom, mFunc,
52 paramName, paramValue));
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)
62 MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
63 GIVE_ME_MS_NOW(), mFrom, mFunc,
64 paramName, paramValue));
67 /* uint32_t constructor */
68 LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
69 const char* paramName, uint32_t paramValue)
70 : mLog(aLog)
71 , mFrom(from)
72 , mFunc(fn)
74 MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
75 GIVE_ME_MS_NOW(), mFrom, mFunc,
76 paramName, paramValue));
79 ~LogScope()
81 MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {EXIT}\n",
82 GIVE_ME_MS_NOW(), mFrom, mFunc));
85 private:
86 mozilla::LogModule* mLog;
87 void* mFrom;
88 const char* mFunc;
91 class LogFunc {
92 public:
93 LogFunc(mozilla::LogModule* aLog, void* from, const char* fn)
95 MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s\n",
96 GIVE_ME_MS_NOW(), from, fn));
99 LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
100 const char* paramName, const char* paramValue)
102 MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\")\n",
103 GIVE_ME_MS_NOW(), from, fn,
104 paramName, paramValue));
107 LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
108 const char* paramName, const void* paramValue)
110 MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%p\")\n",
111 GIVE_ME_MS_NOW(), from, fn,
112 paramName, paramValue));
116 LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
117 const char* paramName, uint32_t paramValue)
119 MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\")\n",
120 GIVE_ME_MS_NOW(), from, fn,
121 paramName, paramValue));
127 class LogMessage {
128 public:
129 LogMessage(mozilla::LogModule* aLog, void* from, const char* fn,
130 const char* msg)
132 MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s -- %s\n",
133 GIVE_ME_MS_NOW(), from, fn, msg));
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__)
143 #define LOG_SCOPE(l, s) \
144 LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l, this, s)
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)
149 #define LOG_FUNC(l, s) LogFunc(l, this, s)
151 #define LOG_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, this, s, pn, pv)
153 #define LOG_STATIC_FUNC(l, s) LogFunc(l, nullptr, s)
155 #define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, nullptr, s, pn, pv)
157 #define LOG_MSG(l, s, m) LogMessage(l, this, s, m)
159 #define LOG_MSG_WITH_PARAM LOG_FUNC_WITH_PARAM
161 #endif // mozilla_image_ImageLogging_h