mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 809950 - fix mtransport logging macros to not introduce static initializers; r=jesup
This commit is contained in:
parent
60b2718413
commit
453525f9d9
@ -12,31 +12,19 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <prlog.h>
|
||||
#include "mozilla/Scoped.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class LogCtx {
|
||||
public:
|
||||
LogCtx(const char* name) : module_(PR_NewLogModule(name)) {}
|
||||
LogCtx(std::string& name) : module_(PR_NewLogModule(name.c_str())) {}
|
||||
|
||||
PRLogModuleInfo* module() const { return module_; }
|
||||
|
||||
private:
|
||||
PRLogModuleInfo* module_;
|
||||
};
|
||||
|
||||
|
||||
#define MOZ_MTLOG_MODULE(n) \
|
||||
static ScopedDeletePtr<LogCtx> mlog_ctx; \
|
||||
static const char *mlog_name = n
|
||||
static PRLogModuleInfo* getLogModule() { \
|
||||
static PRLogModuleInfo* log; \
|
||||
if (!log) \
|
||||
log = PR_NewLogModule(n); \
|
||||
return log; \
|
||||
}
|
||||
|
||||
#define MOZ_MTLOG(level, b) \
|
||||
do { if (!mlog_ctx) mlog_ctx = new LogCtx(mlog_name); \
|
||||
if (mlog_ctx) { \
|
||||
do { \
|
||||
std::stringstream str; \
|
||||
str << b; \
|
||||
PR_LOG(mlog_ctx->module(), level, ("%s", str.str().c_str())); }} while(0)
|
||||
} // close namespace
|
||||
PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); } while(0)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user