KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
logconsumer.h
1/**
2 * @brief A QObject-based sink that receives log entries from the logging system.
3 */
4#ifndef LOGCONSUMER_H
5#define LOGCONSUMER_H
6
7#include <QDateTime>
8#include <QObject>
9#include <Kanoop/logcategory.h>
10#include <Kanoop/log.h>
11#include <Kanoop/logentry.h>
12
13/**
14 * @brief Abstract base class for objects that receive and process log entries.
15 *
16 * Subclass LogConsumer and implement the logEntry() signal handler, or connect
17 * to the logEntry() signal, to receive all log entries delivered to this consumer.
18 * Register the consumer with Log::addConsumer().
19 */
20class KANOOP_EXPORT LogConsumer : public QObject
21{
22 Q_OBJECT
23public:
24 /**
25 * @brief Construct a LogConsumer with an optional parent.
26 * @param parent Optional QObject parent
27 */
28 explicit LogConsumer(QObject *parent = nullptr);
29
30 /** @brief Destructor — automatically unregisters from the system logger. */
31 virtual ~LogConsumer();
32
33 /**
34 * @brief Deliver a log entry to this consumer, emitting the logEntry() signal.
35 * @param entry Log entry to deliver
36 */
37 void addLogEntry(const Log::LogEntry& entry);
38
39signals:
40 /**
41 * @brief Emitted when a new log entry is delivered to this consumer.
42 * @param entry The delivered log entry
43 */
44 void logEntry(const Log::LogEntry& entry);
45};
46
47#endif // LOGCONSUMER_H
A QObject-based sink that receives log entries from the logging system.
Definition logconsumer.h:21
void logEntry(const Log::LogEntry &entry)
Emitted when a new log entry is delivered to this consumer.
virtual ~LogConsumer()
Destructor — automatically unregisters from the system logger.
void addLogEntry(const Log::LogEntry &entry)
Deliver a log entry to this consumer, emitting the logEntry() signal.
LogConsumer(QObject *parent=nullptr)
Construct a LogConsumer with an optional parent.
Immutable record of a single log event.
Definition logentry.h:21