2020-10-01 00:33:19 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include "util/globallog.h"
|
|
|
|
|
|
|
|
GlobalLog* GlobalLog::instance()
|
|
|
|
{
|
2015-07-22 14:48:03 +01:00
|
|
|
static GlobalLog* p = nullptr;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-22 14:48:03 +01:00
|
|
|
if (p == nullptr)
|
2015-07-13 15:16:36 +01:00
|
|
|
p = new GlobalLog();
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return p;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GlobalLog::flush(Log::Level lev)
|
|
|
|
{
|
2020-09-15 02:36:46 +01:00
|
|
|
Q_EMIT newMessage(lev, msg);
|
2015-07-13 15:16:36 +01:00
|
|
|
msg.clear();
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Log::~Log()
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
if (--ref == 0)
|
|
|
|
GlobalLog::instance()->flush(level);
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|