KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
logentry.h
1/**
2 * @brief A single log entry carrying level, category, timestamp, and message text.
3 */
4#ifndef LOGENTRY_H
5#define LOGENTRY_H
6#include <QDateTime>
7#include <QObject>
8#include <Kanoop/logcategory.h>
9#include <Kanoop/log.h>
10
11namespace Log {
12
13/**
14 * @brief Immutable record of a single log event.
15 *
16 * LogEntry objects are created by Logger and delivered to LogConsumer instances.
17 * They capture the severity level, category, timestamp, and both the raw and
18 * pre-formatted message text.
19 */
20class KANOOP_EXPORT LogEntry
21{
22public:
23 /** @brief Default constructor — creates an empty Debug-level entry. */
25
26 /**
27 * @brief Construct a LogEntry with all fields.
28 * @param level Severity level of this entry
29 * @param category Log category associated with this entry
30 * @param timestamp When this entry was generated
31 * @param formattedText Pre-formatted message text (includes level, timestamp, etc.)
32 * @param unformattedText Raw message text without formatting
33 */
34 LogEntry(LogLevel level, const LogCategory& category, const QDateTime& timestamp, const QString& formattedText, const QString& unformattedText) :
35 _level(level), _category(category), _timestamp(timestamp), _formattedText(formattedText), _unformattedText(unformattedText) {}
36
37 /**
38 * @brief Return the severity level.
39 * @return LogLevel of this entry
40 */
41 LogLevel level() const { return _level; }
42
43 /**
44 * @brief Return the log category.
45 * @return LogCategory associated with this entry
46 */
47 Log::LogCategory category() const { return _category; }
48
49 /**
50 * @brief Return the timestamp when this entry was created.
51 * @return QDateTime of the log event
52 */
53 QDateTime timestamp() const { return _timestamp; }
54
55 /**
56 * @brief Return the pre-formatted message text.
57 * @return Message string including level, timestamp, and line number decorations
58 */
59 QString formattedText() const { return _formattedText; }
60
61 /**
62 * @brief Return the raw, unformatted message text.
63 * @return Plain message string without any logging decorations
64 */
65 QString unformattedText() const { return _unformattedText; }
66
67private:
68 LogLevel _level = Debug;
69 Log::LogCategory _category;
70 QDateTime _timestamp;
71 QString _formattedText;
72 QString _unformattedText;
73};
74
75} // namespace Log
76
77
78#endif // LOGENTRY_H
A named logging category with an associated minimum log level.
Definition logcategory.h:34
Immutable record of a single log event.
Definition logentry.h:21
QString formattedText() const
Return the pre-formatted message text.
Definition logentry.h:59
LogEntry()
Default constructor — creates an empty Debug-level entry.
Definition logentry.h:24
QString unformattedText() const
Return the raw, unformatted message text.
Definition logentry.h:65
LogLevel level() const
Return the severity level.
Definition logentry.h:41
Log::LogCategory category() const
Return the log category.
Definition logentry.h:47
LogEntry(LogLevel level, const LogCategory &category, const QDateTime &timestamp, const QString &formattedText, const QString &unformattedText)
Construct a LogEntry with all fields.
Definition logentry.h:34
QDateTime timestamp() const
Return the timestamp when this entry was created.
Definition logentry.h:53
Logging subsystem providing categorized, level-filtered output.
Definition log.h:40
LogLevel
Severity levels for log messages, ordered from most to least critical.
@ Debug
Debug-level messages.
KANOOP_EXPORT LogLevel level()
Return the current minimum log level of the system logger.