26 #include <QFileInfoList>
51 static QDir logFolder;
52 static QString logFileName;
53 const static int numberOfLogs = 10;
54 const static int sizeOfLogs = 1024 * 100;
56 const static auto DEB_HEADER = QLatin1String(
" [DEBG]:\t");
57 const static auto INFO_HEADER = QLatin1String(
" [INFO]:\t");
58 const static auto WARN_HEADER = QLatin1String(
" [WARN]:\t");
59 const static auto CRIT_HEADER = QLatin1String(
" [CRIT]:\t");
60 const static auto DEB_HEADER_CONSOLE = QLatin1String(
"\u001b[38;5;75m[DEBG]:\t");
61 const static auto INFO_HEADER_CONSOLE = QLatin1String(
"\033[32m[INFO]:\t\033[m");
62 const static auto WARN_HEADER_CONSOLE = QLatin1String(
"\033[33m[WARN]:\t\033[m");
63 const static auto CRIT_HEADER_CONSOLE = QLatin1String(
"\033[35m[CRIT]:\t\033[m");
64 const static auto SPACER = QLatin1String(
"\t\t");
65 const static auto D_SPACER = QLatin1String(
"\t\t\t\t");
67 bool init(
bool log_debug =
false);
70 void aMessageHandler(QtMsgType type,
const QMessageLogContext &context,
const QString& msg);
71 inline static const QString timeNow(){
return QTime::currentTime().toString(Qt::ISODate);}
103 #define REPR(cls, str) \
105 QDebug operator<<(QDebug qdb, const cls& object) \
107 qdb << QString(#cls) + '(' + str + ')'; \
The OPL::Log namespace encapsulates constants and functions used to provide logging to files and logg...
Definition: log.cpp:23
void setLogFileName()
setLogFileName sets a log file name ("Log_<Date>_<Time>.txt")
Definition: log.cpp:30
void deleteOldLogs()
Cleans up old logs and initializes logging by preparing and installing a QMessageHandler.
Definition: log.cpp:41
void aMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
aMessageHandler Intercepts Messages and prints to console and log file
Definition: log.cpp:94
bool init(bool log_debug)
initialise logging, clean up logfiles and install a QMessageHandler. To enable logging of debug messa...
Definition: log.cpp:61