12#include <QCoreApplication>
15#include <QStandardPaths>
21static bool _toFile =
false;
25#define MESSAGE_PATTERN \
26"[%{time MM-dd h:mm:ss.zzz} %{threadid} " \
27 "%{if-debug}Debug%{endif}%{if-info}Info%{endif}%{if-warning}Warning%{endif}%{if-critical}Error%{endif}%{if-fatal}Fatal%{endif}] " \
58 if (
logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
66 case QtMsgType::QtFatalMsg:
67 case QtMsgType::QtCriticalMsg:
68 case QtMsgType::QtWarningMsg: {
72 case QtMsgType::QtDebugMsg:
73 case QtMsgType::QtInfoMsg:
90 _verboseLevel = Params::getVerboseLvl();
92 if (Params::isEndable(
"fileLog")) {
94 QString path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
96 " " + QDate::currentDate().toString(Qt::DateFormat::ISODate) +
".log";
97 auto file = Params::getArg(
"fileLog");
void init()
init This method initialize logging of all qt message into file.
The QuasaraAppUtils class This lib include base functions for the all applications of QuasarApp group...
bool checkLogType(QtMsgType type, VerboseLvl lvl)
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
VerboseLvl
The VerboseLvl enum uses for sets log level.
@ Warning
Warning message. This logs will marked as a Warning and printing if the verbose lvl >= 1.
@ Info
General information. This logs will marked as a Info and and printing if the verbose lvl >= 2.
@ Debug
Debug message. This logs will marked as a Debug and printing if the verbose lvl >= 3.
void gen(int size, QByteArray &result)