2001-02-26 07:22:47 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-02-26 07:22:47 +03:00
|
|
|
|
2015-05-07 20:26:00 +03:00
|
|
|
#ifndef mozilla_image_ImageLogging_h
|
|
|
|
#define mozilla_image_ImageLogging_h
|
2011-07-08 21:55:03 +04:00
|
|
|
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2001-05-08 08:01:28 +04:00
|
|
|
#include "prinrval.h"
|
2001-02-26 07:22:47 +03:00
|
|
|
|
2015-11-16 20:21:00 +03:00
|
|
|
static mozilla::LazyLogModule gImgLog("imgRequest");
|
2001-02-26 07:22:47 +03:00
|
|
|
|
2001-05-08 08:01:28 +04:00
|
|
|
#define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
|
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
using mozilla::LogLevel;
|
|
|
|
|
2001-02-26 07:22:47 +03:00
|
|
|
class LogScope {
|
|
|
|
public:
|
2014-12-06 02:12:08 +03:00
|
|
|
|
2015-11-16 20:21:00 +03:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* aFrom, const char* aFunc)
|
2014-12-06 02:12:08 +03:00
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(aFrom)
|
|
|
|
, mFunc(aFunc)
|
2001-02-26 07:22:47 +03:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {ENTER}\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc));
|
2001-02-26 07:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* const char * constructor */
|
2015-11-16 20:21:00 +03:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, const char* paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2001-02-26 07:22:47 +03:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\") {ENTER}\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2001-02-26 07:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* void ptr constructor */
|
2015-11-16 20:21:00 +03:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, const void* paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2001-02-26 07:22:47 +03:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=%p) {ENTER}\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2001-02-26 07:22:47 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
/* int32_t constructor */
|
2015-11-16 20:21:00 +03:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, int32_t paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2001-02-26 07:22:47 +03:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2001-02-26 07:22:47 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
/* uint32_t constructor */
|
2015-11-16 20:21:00 +03:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, uint32_t paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2001-02-26 07:22:47 +03:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2001-02-26 07:22:47 +03:00
|
|
|
}
|
|
|
|
|
2015-01-10 21:49:00 +03:00
|
|
|
~LogScope()
|
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {EXIT}\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc));
|
2001-02-26 07:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-11-16 20:21:00 +03:00
|
|
|
mozilla::LogModule* mLog;
|
2014-12-06 02:12:08 +03:00
|
|
|
void* mFrom;
|
|
|
|
const char* mFunc;
|
2001-02-26 07:22:47 +03:00
|
|
|
};
|
|
|
|
|
2001-05-08 08:01:28 +04:00
|
|
|
class LogFunc {
|
|
|
|
public:
|
2015-11-16 20:21:00 +03:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn)
|
2001-05-08 08:01:28 +04:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s\n",
|
2014-01-09 00:51:38 +04:00
|
|
|
GIVE_ME_MS_NOW(), from, fn));
|
2001-05-08 08:01:28 +04:00
|
|
|
}
|
|
|
|
|
2015-11-16 20:21:00 +03:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, const char* paramValue)
|
2001-05-08 08:01:28 +04:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\")\n",
|
2014-01-09 00:51:38 +04:00
|
|
|
GIVE_ME_MS_NOW(), from, fn,
|
|
|
|
paramName, paramValue));
|
2001-05-08 08:01:28 +04:00
|
|
|
}
|
|
|
|
|
2015-11-16 20:21:00 +03:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, const void* paramValue)
|
2001-05-08 08:01:28 +04:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%p\")\n",
|
2014-01-09 00:51:38 +04:00
|
|
|
GIVE_ME_MS_NOW(), from, fn,
|
|
|
|
paramName, paramValue));
|
2001-05-08 08:01:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-16 20:21:00 +03:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* paramName, uint32_t paramValue)
|
2001-05-08 08:01:28 +04:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\")\n",
|
2014-12-06 02:12:08 +03:00
|
|
|
GIVE_ME_MS_NOW(), from, fn,
|
2014-01-09 00:51:38 +04:00
|
|
|
paramName, paramValue));
|
2001-05-08 08:01:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LogMessage {
|
|
|
|
public:
|
2015-11-16 20:21:00 +03:00
|
|
|
LogMessage(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-06 02:12:08 +03:00
|
|
|
const char* msg)
|
2001-05-08 08:01:28 +04:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s -- %s\n",
|
2014-01-09 00:51:38 +04:00
|
|
|
GIVE_ME_MS_NOW(), from, fn, msg));
|
2001-05-08 08:01:28 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-31 00:28:49 +04:00
|
|
|
#define LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
|
2014-12-06 02:12:08 +03:00
|
|
|
#define LOG_SCOPE_APPEND_LINE_NUMBER_EXPAND(id, line) \
|
|
|
|
LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line)
|
|
|
|
#define LOG_SCOPE_APPEND_LINE_NUMBER(id) \
|
|
|
|
LOG_SCOPE_APPEND_LINE_NUMBER_EXPAND(id, __LINE__)
|
2012-01-31 00:28:49 +04:00
|
|
|
|
2001-02-26 07:22:47 +03:00
|
|
|
#define LOG_SCOPE(l, s) \
|
2014-01-09 00:51:38 +04:00
|
|
|
LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l, this, s)
|
2001-02-26 07:22:47 +03:00
|
|
|
|
|
|
|
#define LOG_SCOPE_WITH_PARAM(l, s, pn, pv) \
|
2014-01-09 00:51:38 +04:00
|
|
|
LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l, this, s, pn, pv)
|
|
|
|
|
|
|
|
#define LOG_FUNC(l, s) LogFunc(l, this, s)
|
|
|
|
|
|
|
|
#define LOG_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, this, s, pn, pv)
|
|
|
|
|
|
|
|
#define LOG_STATIC_FUNC(l, s) LogFunc(l, nullptr, s)
|
|
|
|
|
|
|
|
#define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, nullptr, s, pn, pv)
|
|
|
|
|
|
|
|
#define LOG_MSG(l, s, m) LogMessage(l, this, s, m)
|
2001-05-08 08:01:28 +04:00
|
|
|
|
|
|
|
#define LOG_MSG_WITH_PARAM LOG_FUNC_WITH_PARAM
|
2011-07-08 21:55:03 +04:00
|
|
|
|
2015-05-07 20:26:00 +03:00
|
|
|
#endif // mozilla_image_ImageLogging_h
|