refactor: Logger::instance return a pointer to the logger static object
This commit is contained in:
committed by
Chris Rizzitello
parent
78eae652fd
commit
c066e394a8
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
||||
qInfo("%s v%s", kAppName, kDisplayVersion);
|
||||
|
||||
dotenv();
|
||||
Logger::instance().loadEnvVars();
|
||||
Logger::instance()->loadEnvVars();
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
||||
|
||||
@ -23,8 +23,6 @@ const auto kForceDebugMessages = QStringList{
|
||||
"Unable to obtain clipboard."
|
||||
};
|
||||
|
||||
Logger Logger::s_instance;
|
||||
|
||||
QString printLine(FILE *out, const QString &type, const QString &message, const QString &fileLine = "")
|
||||
{
|
||||
|
||||
|
||||
@ -15,9 +15,10 @@ class Logger : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Logger &instance()
|
||||
static Logger *instance()
|
||||
{
|
||||
return s_instance;
|
||||
static Logger m;
|
||||
return &m;
|
||||
}
|
||||
|
||||
void loadEnvVars();
|
||||
@ -27,7 +28,6 @@ Q_SIGNALS:
|
||||
void newLine(const QString &line);
|
||||
|
||||
private:
|
||||
static Logger s_instance;
|
||||
#ifdef NDEBUG
|
||||
bool m_debug = false;
|
||||
#else
|
||||
|
||||
@ -90,7 +90,7 @@ QString fileLine(const QMessageLogContext &context)
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||
{
|
||||
const auto fileLine = messages::fileLine(context);
|
||||
Logger::instance().handleMessage(type, fileLine, message);
|
||||
Logger::instance()->handleMessage(type, fileLine, message);
|
||||
|
||||
if (type == QtFatalMsg || type == QtCriticalMsg) {
|
||||
showErrorDialog(message, fileLine, type);
|
||||
|
||||
@ -31,7 +31,7 @@ LogWidget::LogWidget(QWidget *parent) : QWidget{parent}, m_textLog{new QPlainTex
|
||||
setLayout(layout);
|
||||
|
||||
connect(
|
||||
&deskflow::gui::Logger::instance(), &deskflow::gui::Logger::newLine, m_textLog, &QPlainTextEdit::appendPlainText
|
||||
deskflow::gui::Logger::instance(), &deskflow::gui::Logger::newLine, m_textLog, &QPlainTextEdit::appendPlainText
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user