logging: Break out stderr logging sink into separate function
Change-Id: I4bc476376d2b84297c1798b016017db496532d27 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a29e1fc708
commit
9b800b55c1
@ -1244,7 +1244,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
|
|||||||
static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"),
|
static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"),
|
||||||
QRegularExpression::OptimizeOnFirstUsageOption);
|
QRegularExpression::OptimizeOnFirstUsageOption);
|
||||||
|
|
||||||
QVarLengthArray<void*, 32> buffer(7 + frameCount);
|
QVarLengthArray<void*, 32> buffer(8 + frameCount);
|
||||||
int n = backtrace(buffer.data(), buffer.size());
|
int n = backtrace(buffer.data(), buffer.size());
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int numberPrinted = 0;
|
int numberPrinted = 0;
|
||||||
@ -1638,6 +1638,19 @@ static bool win_message_handler(QtMsgType type, const QMessageLogContext &contex
|
|||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void stderr_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||||
|
{
|
||||||
|
QString formattedMessage = qFormatLogMessage(type, context, message);
|
||||||
|
|
||||||
|
// print nothing if message pattern didn't apply / was empty.
|
||||||
|
// (still print empty lines, e.g. because message itself was empty)
|
||||||
|
if (formattedMessage.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
fprintf(stderr, "%s\n", formattedMessage.toLocal8Bit().constData());
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
@ -1666,18 +1679,8 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (handledStderr)
|
if (!handledStderr)
|
||||||
return;
|
stderr_message_handler(type, context, message);
|
||||||
|
|
||||||
QString formattedMessage = qFormatLogMessage(type, context, message);
|
|
||||||
|
|
||||||
// print nothing if message pattern didn't apply / was empty.
|
|
||||||
// (still print empty lines, e.g. because message itself was empty)
|
|
||||||
if (formattedMessage.isNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
fprintf(stderr, "%s\n", formattedMessage.toLocal8Bit().constData());
|
|
||||||
fflush(stderr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
Reference in New Issue
Block a user