Add QDebug convenience for changing the verbosity level

qDebug().nospace().verbosity(3) << myObj;

Change-Id: Idea3094294d1afbff302e472e47a55a01d3b7735
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Tor Arne Vestbø 2018-12-19 16:46:20 +01:00
parent 4e55d8b50b
commit 0d65c71a19
2 changed files with 13 additions and 0 deletions

View File

@ -475,6 +475,17 @@ QDebug &QDebug::resetFormat()
\sa verbosity()
*/
/*!
\fn QDebug &QDebug::verbosity(int verbosityLevel)
\since 5.13
Sets the verbosity of the stream to \a verbosityLevel and returns a reference to the stream.
The allowed range is from 0 to 7. The default value is 2.
\sa verbosity(), setVerbosity()
*/
/*!
\fn QDebug &QDebug::operator<<(QChar t)

View File

@ -123,6 +123,7 @@ public:
inline QDebug &space() { stream->space = true; stream->ts << ' '; return *this; }
inline QDebug &nospace() { stream->space = false; return *this; }
inline QDebug &maybeSpace() { if (stream->space) stream->ts << ' '; return *this; }
inline QDebug &verbosity(int verbosityLevel) { setVerbosity(verbosityLevel); return *this; }
int verbosity() const { return stream->verbosity(); }
void setVerbosity(int verbosityLevel) { stream->setVerbosity(verbosityLevel); }
@ -195,6 +196,7 @@ public:
inline QNoDebug &quote() { return *this; }
inline QNoDebug &noquote() { return *this; }
inline QNoDebug &maybeQuote(const char = '"') { return *this; }
inline QNoDebug &verbosity(int) { return *this; }
template<typename T>
inline QNoDebug &operator<<(const T &) { return *this; }