20#include "loggingtypes.h"
21#include <Kanoop/kanoopcommon.h>
24#define LVL_EMERGENCY __FILE__,__LINE__,Log::LogLevel::Emergency
25#define LVL_ALERT __FILE__,__LINE__,Log::LogLevel::Alert
26#define LVL_CRITICAL __FILE__,__LINE__,Log::LogLevel::Critical
27#define LVL_ERROR __FILE__,__LINE__,Log::LogLevel::Error
28#define LVL_WARNING __FILE__,__LINE__,Log::LogLevel::Warning
29#define LVL_NOTICE __FILE__,__LINE__,Log::LogLevel::Notice
30#define LVL_INFO __FILE__,__LINE__,Log::LogLevel::Info
31#define LVL_DEBUG __FILE__,__LINE__,Log::LogLevel::Debug
42class LogCategoryPrivate;
74 void logText(
const char* file,
int lineNumber,
LogLevel level,
const QString& text);
94 void logHex(
const char* file,
int lineNumber,
LogLevel level,
const QByteArray& data,
const QString& tag = QString());
105 void logHex(
const char* file,
int lineNumber,
LogLevel level,
const LogCategory& category,
const QByteArray& data,
const QString& tag = QString());
213 class CategoryIndex :
public QMap<QString, LogCategoryPrivate*>
228 void outputToDestinations(LogLevel level,
const LogCategory& category,
const QDateTime& timestamp,
const QString& formattedText,
const QString& unformattedText);
231 static QString bufferToHex(
const QByteArray& buffer);
243 QList<LogConsumer*> _surplusConsumers;
248 CategoryIndex _categories;
250 static const QList<QString> _LevelStrings;
291KANOOP_EXPORT
void logHex(
const char* file,
int lineNumber,
LogLevel level,
const QByteArray& data,
const QString& tag = QString());
A QObject-based sink that receives log entries from the logging system.
A named logging category with an associated minimum log level.
Core logger class supporting console, file, syslog, and consumer outputs.
void logText(const char *file, int lineNumber, LogLevel level, const LogCategory &category, const QString &text)
Write a categorized text message to the log.
void openLog()
Open the log file or syslog connection as configured.
LogCategory registerCategory(const QString &name)
Register a new log category by name.
void disableOutputFlags(OutputFlags flags)
Disable specific output flags without affecting others.
void logHex(const char *file, int lineNumber, LogLevel level, const QByteArray &data, const QString &tag=QString())
Write a hex dump of a byte array to the log.
void enableOutputFlags(OutputFlags flags)
Enable additional output flags without clearing existing ones.
void setIdentity(const QString &value)
Set the syslog identity string.
void setFlags(OutputFlags flags)
Set the output flags, replacing any existing flags.
OutputFlags flags() const
Return the active output flags.
void setLevel(LogLevel value)
Set the minimum log level; messages below this level are discarded.
QString filename() const
Return the log file path.
void removeConsumer(LogConsumer *consumer)
Remove a previously added log consumer.
LogLevel level() const
Return the current minimum log level.
QString identity() const
Return the syslog identity string.
Logger()
Default constructor — initializes an unopened logger at Debug level.
void logHex(const char *file, int lineNumber, LogLevel level, const LogCategory &category, const QByteArray &data, const QString &tag=QString())
Write a categorized hex dump to the log.
LogCategory registerCategory(const LogCategory &category)
Register an existing LogCategory object.
bool isLogOpen() const
Test whether the log is open and ready to write.
void addConsumer(LogConsumer *consumer)
Add an external log consumer to receive log entries.
void setFilename(const QString &filename)
Set the log file path and reopen the file.
void rotateLog(const QString &newFileName)
Rotate the log to a new file path.
QList< LogCategory > categories() const
Return all registered log categories.
void logText(const char *file, int lineNumber, LogLevel level, const QString &text)
Write a text message to the log.
void setCategoryLevel(const QString &name, LogLevel level)
Override the log level for a specific category.
Logging subsystem providing categorized, level-filtered output.
KANOOP_EXPORT void setFilename(const QString &filename)
Set the log file path of the system logger.
KANOOP_EXPORT void logHex(const char *file, int lineNumber, LogLevel level, const LogCategory &category, const QByteArray &data, const QString &tag=QString())
Write a categorized hex dump via the system logger.
KANOOP_EXPORT LogCategory registerCategory(const QString &name)
Register a log category by name with the system logger.
KANOOP_EXPORT QList< LogCategory > categories()
Return all categories registered with the system logger.
LogLevel
Severity levels for log messages, ordered from most to least critical.
KANOOP_EXPORT OutputFlags flags()
Return the output flags of the system logger.
KANOOP_EXPORT void setCategoryLevel(const QString &name, LogLevel level)
Override the log level for a named category on the system logger.
KANOOP_EXPORT void logText(const char *file, int lineNumber, LogLevel level, const QString &text)
Write a text message via the system logger.
KANOOP_EXPORT void setIdentity(const QString &value)
Set the syslog identity of the system logger.
KANOOP_EXPORT void setLevel(LogLevel value)
Set the minimum log level of the system logger.
KANOOP_EXPORT void disableOutputFlags(OutputFlags flags)
Disable specific output flags on the system logger.
KANOOP_EXPORT LogLevel parseLevel(const QString &value, bool *parsed=nullptr)
Parse a log level name string into a LogLevel enum value.
KANOOP_EXPORT void addConsumer(LogConsumer *consumer)
Add an external log consumer to the system logger.
KANOOP_EXPORT QString identity()
Return the syslog identity of the system logger.
KANOOP_EXPORT QString filename()
Return the log file path of the system logger.
KANOOP_EXPORT void setFlags(OutputFlags flags)
Set the output flags of the system logger.
KANOOP_EXPORT LogLevel level()
Return the current minimum log level of the system logger.
KANOOP_EXPORT void enableOutputFlags(OutputFlags flags)
Enable additional output flags on the system logger.
KANOOP_EXPORT void removeConsumer(LogConsumer *consumer)
Remove an external log consumer from the system logger.
KANOOP_EXPORT Logger * systemLog()
Return the process-wide Logger singleton.
OutputFlags
Bitmask flags controlling where log output is sent.
KANOOP_EXPORT QDateTime getLogStartTime(const QString &filename)
Read the start timestamp from an existing log file.
KANOOP_EXPORT QDateTime getLogEndTime(const QString &filename)
Read the end timestamp from an existing log file.