forked from quickshell/quickshell
core/log: add timestamps to log files
This commit is contained in:
parent
38ba3fff24
commit
7c7326ec52
3 changed files with 25 additions and 5 deletions
|
@ -2,18 +2,26 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include <qdatetime.h>
|
||||
#include <qlogging.h>
|
||||
#include <qobject.h>
|
||||
#include <qtextstream.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
struct LogMessage {
|
||||
explicit LogMessage(QtMsgType type, const char* category, QByteArray body)
|
||||
explicit LogMessage(
|
||||
QtMsgType type,
|
||||
const char* category,
|
||||
QByteArray body,
|
||||
QDateTime time = QDateTime::currentDateTime()
|
||||
)
|
||||
: type(type)
|
||||
, time(std::move(time))
|
||||
, category(category)
|
||||
, body(std::move(body)) {}
|
||||
|
||||
QtMsgType type;
|
||||
QDateTime time;
|
||||
const char* category;
|
||||
QByteArray body;
|
||||
};
|
||||
|
@ -24,7 +32,7 @@ class LogManager: public QObject {
|
|||
public:
|
||||
static LogManager* instance();
|
||||
|
||||
static void formatMessage(QTextStream& stream, const LogMessage& msg, bool color);
|
||||
static void formatMessage(QTextStream& stream, const LogMessage& msg, bool color, bool timestamp);
|
||||
|
||||
signals:
|
||||
void logMessage(LogMessage msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue