Skip to content

Commit

Permalink
fix getLogString, flush fatal log stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 committed Nov 5, 2024
1 parent 4e5655a commit e909bad
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fatal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <cstdio> // for vsnprintf
#include <cstdlib> // for exit

#include <QByteArray> // for QByteArray
#include <QDebug> // for QDebug
#include <QString> // for QString
#include <QtGlobal> // for qCritical, qDebug, qInfo, qWarning

#include "defs.h" // for DebugLog, gbFatal, gbDebug, gbInfo, gbWarning
Expand Down Expand Up @@ -59,6 +59,7 @@ gbFatal(const char* fmt, ...)
va_list args;
va_start(args, fmt);
gbVLog(QtCriticalMsg, fmt, args);
gbFlush(QtCriticalMsg);
va_end(args);
exit(1);
}
Expand Down Expand Up @@ -97,24 +98,23 @@ static QString gbCriticalLogString_;

static QString& getLogString(QtMsgType type)
{
QString& logString = gbDebugLogString_;
switch (type)
{
case QtDebugMsg:
logString = gbDebugLogString_;
return gbDebugLogString_;
break;
case QtInfoMsg:
logString = gbInfoLogString_;
return gbInfoLogString_;
break;
case QtWarningMsg:
logString = gbWarningLogString_;
return gbWarningLogString_;
break;
case QtCriticalMsg:
case QtFatalMsg:
logString = gbCriticalLogString_;
default:
return gbCriticalLogString_;
break;
}
return logString;
}

static void sendLogMsg(QtMsgType type, const QString& msg)
Expand All @@ -132,6 +132,7 @@ static void sendLogMsg(QtMsgType type, const QString& msg)
break;
case QtCriticalMsg:
case QtFatalMsg:
default:
qCritical().noquote() << msg;
break;
}
Expand Down

0 comments on commit e909bad

Please sign in to comment.