mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 958596 - Allow writing a log statement that does not end in a newline. r=Bas
This commit is contained in:
parent
fa0ea774fa
commit
d4d1d77eca
@ -14,6 +14,7 @@
|
|||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
#include "BaseRect.h"
|
#include "BaseRect.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
|
#include "mozilla/TypedEnum.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// This file gets included from nsGlobalWindow.cpp, which doesn't like
|
// This file gets included from nsGlobalWindow.cpp, which doesn't like
|
||||||
@ -80,12 +81,20 @@ public:
|
|||||||
NoLog &operator <<(const T &aLogText) { return *this; }
|
NoLog &operator <<(const T &aLogText) { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MOZ_BEGIN_ENUM_CLASS(LogOptions, int)
|
||||||
|
NoNewline = 0x01
|
||||||
|
MOZ_END_ENUM_CLASS(LogOptions)
|
||||||
|
|
||||||
template<int L>
|
template<int L>
|
||||||
class Log
|
class Log
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Log() {}
|
Log(LogOptions aOptions = LogOptions(0)) : mOptions(aOptions) {}
|
||||||
~Log() { mMessage << '\n'; WriteLog(mMessage.str()); }
|
~Log() {
|
||||||
|
if (!(int(mOptions) & int(LogOptions::NoNewline)))
|
||||||
|
mMessage << '\n';
|
||||||
|
WriteLog(mMessage.str());
|
||||||
|
}
|
||||||
|
|
||||||
Log &operator <<(char aChar) { mMessage << aChar; return *this; }
|
Log &operator <<(char aChar) { mMessage << aChar; return *this; }
|
||||||
Log &operator <<(const std::string &aLogText) { mMessage << aLogText; return *this; }
|
Log &operator <<(const std::string &aLogText) { mMessage << aLogText; return *this; }
|
||||||
@ -117,6 +126,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream mMessage;
|
std::stringstream mMessage;
|
||||||
|
LogOptions mOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Log<LOG_DEBUG> DebugLog;
|
typedef Log<LOG_DEBUG> DebugLog;
|
||||||
|
Loading…
Reference in New Issue
Block a user