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"
13 static mozilla::LazyLogModule
gImgLog("imgRequest");
15 #define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
17 using mozilla::LogLevel
;
22 LogScope(mozilla::LogModule
* aLog
, void* aFrom
, const char* 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
)
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
)
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
)
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
)
74 MOZ_LOG(mLog
, LogLevel::Debug
, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
75 GIVE_ME_MS_NOW(), mFrom
, mFunc
,
76 paramName
, paramValue
));
81 MOZ_LOG(mLog
, LogLevel::Debug
, ("%d [this=%p] %s {EXIT}\n",
82 GIVE_ME_MS_NOW(), mFrom
, mFunc
));
86 mozilla::LogModule
* mLog
;
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
));
129 LogMessage(mozilla::LogModule
* aLog
, void* from
, const char* fn
,
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