2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-05-07 10:26:00 -07:00
|
|
|
#ifndef mozilla_image_ImageLogging_h
|
|
|
|
#define mozilla_image_ImageLogging_h
|
2011-07-08 10:55:03 -07:00
|
|
|
|
2015-05-19 11:15:34 -07:00
|
|
|
#include "mozilla/Logging.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prinrval.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
2015-11-16 09:21:00 -08:00
|
|
|
static mozilla::LazyLogModule gImgLog("imgRequest");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
|
|
|
|
|
2015-06-03 15:25:57 -07:00
|
|
|
using mozilla::LogLevel;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class LogScope {
|
|
|
|
public:
|
2014-12-05 15:12:08 -08:00
|
|
|
|
2015-11-16 09:21:00 -08:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* aFrom, const char* aFunc)
|
2014-12-05 15:12:08 -08:00
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(aFrom)
|
|
|
|
, mFunc(aFunc)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {ENTER}\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* const char * constructor */
|
2015-11-16 09:21:00 -08:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, const char* paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\") {ENTER}\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* void ptr constructor */
|
2015-11-16 09:21:00 -08:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, const void* paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=%p) {ENTER}\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
/* int32_t constructor */
|
2015-11-16 09:21:00 -08:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, int32_t paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
/* uint32_t constructor */
|
2015-11-16 09:21:00 -08:00
|
|
|
LogScope(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, uint32_t paramValue)
|
|
|
|
: mLog(aLog)
|
|
|
|
, mFrom(from)
|
|
|
|
, mFunc(fn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc,
|
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2015-01-10 10:49:00 -08:00
|
|
|
~LogScope()
|
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(mLog, LogLevel::Debug, ("%d [this=%p] %s {EXIT}\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), mFrom, mFunc));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-11-16 09:21:00 -08:00
|
|
|
mozilla::LogModule* mLog;
|
2014-12-05 15:12:08 -08:00
|
|
|
void* mFrom;
|
|
|
|
const char* mFunc;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class LogFunc {
|
|
|
|
public:
|
2015-11-16 09:21:00 -08:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s\n",
|
2014-01-08 12:51:38 -08:00
|
|
|
GIVE_ME_MS_NOW(), from, fn));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2015-11-16 09:21:00 -08:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, const char* paramValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%s\")\n",
|
2014-01-08 12:51:38 -08:00
|
|
|
GIVE_ME_MS_NOW(), from, fn,
|
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2015-11-16 09:21:00 -08:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, const void* paramValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%p\")\n",
|
2014-01-08 12:51:38 -08:00
|
|
|
GIVE_ME_MS_NOW(), from, fn,
|
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-16 09:21:00 -08:00
|
|
|
LogFunc(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* paramName, uint32_t paramValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s (%s=\"%d\")\n",
|
2014-12-05 15:12:08 -08:00
|
|
|
GIVE_ME_MS_NOW(), from, fn,
|
2014-01-08 12:51:38 -08:00
|
|
|
paramName, paramValue));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LogMessage {
|
|
|
|
public:
|
2015-11-16 09:21:00 -08:00
|
|
|
LogMessage(mozilla::LogModule* aLog, void* from, const char* fn,
|
2014-12-05 15:12:08 -08:00
|
|
|
const char* msg)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-06-03 15:25:57 -07:00
|
|
|
MOZ_LOG(aLog, LogLevel::Debug, ("%d [this=%p] %s -- %s\n",
|
2014-01-08 12:51:38 -08:00
|
|
|
GIVE_ME_MS_NOW(), from, fn, msg));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-30 12:28:49 -08:00
|
|
|
#define LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
|
2014-12-05 15:12:08 -08: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-30 12:28:49 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define LOG_SCOPE(l, s) \
|
2014-01-08 12:51:38 -08:00
|
|
|
LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l, this, s)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define LOG_SCOPE_WITH_PARAM(l, s, pn, pv) \
|
2014-01-08 12:51:38 -08: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)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define LOG_MSG_WITH_PARAM LOG_FUNC_WITH_PARAM
|
2011-07-08 10:55:03 -07:00
|
|
|
|
2015-05-07 10:26:00 -07:00
|
|
|
#endif // mozilla_image_ImageLogging_h
|