Skip to content

Commit

Permalink
[embedlite] Fix EmbedLog to use MOZ_LOG. Fixes JB#37154
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Dec 19, 2016
1 parent 32dbbc8 commit d23e956
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions embedding/embedlite/EmbedInitGlue.h
Expand Up @@ -79,6 +79,7 @@ static inline bool IsLibXulInThePath(const char* path, std::string& xpcomPath)
#endif
}


bool LoadEmbedLite(int argc = 0, char** argv = 0)
{
if (XRE_GetEmbedLite) {
Expand Down
2 changes: 2 additions & 0 deletions embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "EmbedLog.h"
#include "mozilla/Logging.h"

#include "EmbedLiteApp.h"
#include "nsISupports.h"
Expand Down Expand Up @@ -43,6 +44,7 @@ EmbedLiteApp*
EmbedLiteApp::GetInstance()
{
if (!sSingleton) {
mozilla::LogModule::Init();
sSingleton = new EmbedLiteApp();
NS_ASSERTION(sSingleton, "not initialized");
}
Expand Down
10 changes: 5 additions & 5 deletions embedding/embedlite/utils/EmbedLog.cpp
Expand Up @@ -9,15 +9,15 @@

#ifdef PR_LOGGING

PRLogModuleInfo*
LogModule*
GetEmbedCommonLog(const char* aModule)
{
static std::map<std::string, PRLogModuleInfo*> sLogMap;
std::map<std::string, PRLogModuleInfo*>::iterator it = sLogMap.find(aModule);
PRLogModuleInfo* retVal;
static std::map<std::string, LogModule*> sLogMap;
std::map<std::string, LogModule*>::iterator it = sLogMap.find(aModule);
LogModule* retVal;
if (sLogMap.end() == it) {
printf("Created LOG for %s\n", aModule);
sLogMap[aModule] = retVal = PR_NewLogModule(aModule);
sLogMap[aModule] = retVal = LazyLogModule(aModule);
} else {
retVal = it->second;
}
Expand Down
20 changes: 9 additions & 11 deletions embedding/embedlite/utils/EmbedLog.h
Expand Up @@ -7,24 +7,21 @@
#define MOZ_EMBED_LOG_H

#include <stdio.h>

#define PR_LOGGING 1
#include "Logging.h"

#ifdef PR_LOGGING

#ifdef EMBED_LITE_INTERNAL

#include "prlog.h"

extern PRLogModuleInfo* GetEmbedCommonLog(const char* aModule);
extern mozilla::LogModule* GetEmbedCommonLog(const char* aModule);

#define LOGF(FMT, ...) PR_LOG(GetEmbedCommonLog("EmbedLite"), PR_LOG_ALWAYS, ("FUNC::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGT(FMT, ...) PR_LOG(GetEmbedCommonLog("EmbedLite"), PR_LOG_DEBUG, ("TRACE::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGW(FMT, ...) PR_LOG(GetEmbedCommonLog("EmbedLite"), PR_LOG_WARNING, ("WARN: EmbedLite::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGE(FMT, ...) PR_LOG(GetEmbedCommonLog("EmbedLite"), PR_LOG_ERROR, ("ERROR: EmbedLite::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGNI(FMT, ...) PR_LOG(GetEmbedCommonLog("EmbedLite"), PR_LOG_ALWAYS, ("NON_IMPL: EmbedLite::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGF(FMT, ...) MOZ_LOG(GetEmbedCommonLog("EmbedLite"), mozilla::LogLevel::Error, ("FUNC::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGT(FMT, ...) MOZ_LOG(GetEmbedCommonLog("EmbedLite"), mozilla::LogLevel::Debug, ("TRACE::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGW(FMT, ...) MOZ_LOG(GetEmbedCommonLog("EmbedLite"), mozilla::LogLevel::Info, ("WARN: EmbedLite::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGE(FMT, ...) MOZ_LOG(GetEmbedCommonLog("EmbedLite"), mozilla::LogLevel::Warning, ("ERROR: EmbedLite::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGNI(FMT, ...) MOZ_LOG(GetEmbedCommonLog("EmbedLite"), mozilla::LogLevel::Error, ("NON_IMPL: EmbedLite::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))

#define LOGC(CUSTOMNAME, FMT, ...) PR_LOG(GetEmbedCommonLog(CUSTOMNAME), PR_LOG_WARNING, (CUSTOMNAME "::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))
#define LOGC(CUSTOMNAME, FMT, ...) MOZ_LOG(GetEmbedCommonLog(CUSTOMNAME), mozilla::LogLevel::Info, (CUSTOMNAME "::%s:%d " FMT , __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__))

#else // EMBED_LITE_INTERNAL

Expand All @@ -39,6 +36,7 @@ extern PRLogModuleInfo* GetEmbedCommonLog(const char* aModule);
#define LOGT(...) do {} while (0)
#define LOGW(...) do {} while (0)
#define LOGE(...) do {} while (0)
#define LOGNI(...) do {} while (0)
#define LOGC(...) do {} while (0)

#endif // PR_LOGGING
Expand Down

0 comments on commit d23e956

Please sign in to comment.