forked from quickshell/quickshell
core/log: add filesystem logger
This commit is contained in:
parent
46f48f2f87
commit
6bf4826ae7
9 changed files with 299 additions and 53 deletions
|
@ -1,6 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
class LogManager {
|
||||
public:
|
||||
static void setup();
|
||||
#include <utility>
|
||||
|
||||
#include <qlogging.h>
|
||||
#include <qobject.h>
|
||||
#include <qtextstream.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
struct LogMessage {
|
||||
explicit LogMessage(QtMsgType type, const char* category, QByteArray body)
|
||||
: type(type)
|
||||
, category(category)
|
||||
, body(std::move(body)) {}
|
||||
|
||||
QtMsgType type;
|
||||
const char* category;
|
||||
QByteArray body;
|
||||
};
|
||||
|
||||
class LogManager: public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
static LogManager* instance();
|
||||
|
||||
static void formatMessage(QTextStream& stream, const LogMessage& msg, bool color);
|
||||
|
||||
signals:
|
||||
void logMessage(LogMessage msg);
|
||||
|
||||
private:
|
||||
explicit LogManager();
|
||||
static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||
|
||||
bool colorLogs;
|
||||
QTextStream stdoutStream;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue