|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
Core logger class supporting console, file, syslog, and consumer outputs. More...
#include <log.h>
Public Member Functions | |
| Logger () | |
| Default constructor — initializes an unopened logger at Debug level. | |
| void | openLog () |
| Open the log file or syslog connection as configured. | |
| void | rotateLog (const QString &newFileName) |
| Rotate the log to a new file path. | |
| void | logText (const char *file, int lineNumber, LogLevel level, const QString &text) |
| Write a text message to the log. | |
| void | logText (const char *file, int lineNumber, LogLevel level, const LogCategory &category, const QString &text) |
| Write a categorized text message to the log. | |
| 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 | 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. | |
| LogLevel | level () const |
| Return the current minimum log level. | |
| void | setLevel (LogLevel value) |
| Set the minimum log level; messages below this level are discarded. | |
| OutputFlags | flags () const |
| Return the active output flags. | |
| void | setFlags (OutputFlags flags) |
| Set the output flags, replacing any existing flags. | |
| void | enableOutputFlags (OutputFlags flags) |
| Enable additional output flags without clearing existing ones. | |
| void | disableOutputFlags (OutputFlags flags) |
| Disable specific output flags without affecting others. | |
| QString | filename () const |
| Return the log file path. | |
| void | setFilename (const QString &filename) |
| Set the log file path and reopen the file. | |
| QString | identity () const |
| Return the syslog identity string. | |
| void | setIdentity (const QString &value) |
| Set the syslog identity string. | |
| LogCategory | registerCategory (const QString &name) |
| Register a new log category by name. | |
| LogCategory | registerCategory (const LogCategory &category) |
| Register an existing LogCategory object. | |
| QList< LogCategory > | categories () const |
| Return all registered log categories. | |
| void | setCategoryLevel (const QString &name, LogLevel level) |
| Override the log level for a specific category. | |
| void | addConsumer (LogConsumer *consumer) |
| Add an external log consumer to receive log entries. | |
| void | removeConsumer (LogConsumer *consumer) |
| Remove a previously added log consumer. | |
| bool | isLogOpen () const |
| Test whether the log is open and ready to write. | |
Core logger class supporting console, file, syslog, and consumer outputs.
Logger is typically accessed through the module-level free functions (Log::logText, etc.) which delegate to a process-wide singleton returned by Log::systemLog().
| void Log::Logger::addConsumer | ( | LogConsumer * | consumer | ) |
Add an external log consumer to receive log entries.
| consumer | Consumer to add |
| QList< LogCategory > Log::Logger::categories | ( | ) | const |
Return all registered log categories.
| void Log::Logger::disableOutputFlags | ( | OutputFlags | flags | ) |
Disable specific output flags without affecting others.
| flags | Flags to disable |
| void Log::Logger::enableOutputFlags | ( | OutputFlags | flags | ) |
Enable additional output flags without clearing existing ones.
| flags | Flags to enable |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void Log::Logger::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.
| file | Source filename (use FILE) |
| lineNumber | Source line number (use LINE) |
| level | Severity level of this message |
| category | Log category for filtering |
| data | Bytes to dump |
| tag | Optional label prepended to the dump |
| void Log::Logger::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.
| file | Source filename (use FILE) |
| lineNumber | Source line number (use LINE) |
| level | Severity level of this message |
| data | Bytes to dump |
| tag | Optional label prepended to the dump |
| void Log::Logger::logText | ( | const char * | file, |
| int | lineNumber, | ||
| LogLevel | level, | ||
| const LogCategory & | category, | ||
| const QString & | text | ||
| ) |
Write a categorized text message to the log.
| file | Source filename (use FILE) |
| lineNumber | Source line number (use LINE) |
| level | Severity level of this message |
| category | Log category for filtering |
| text | Message text to log |
| void Log::Logger::logText | ( | const char * | file, |
| int | lineNumber, | ||
| LogLevel | level, | ||
| const QString & | text | ||
| ) |
Write a text message to the log.
| file | Source filename (use FILE) |
| lineNumber | Source line number (use LINE) |
| level | Severity level of this message |
| text | Message text to log |
| LogCategory Log::Logger::registerCategory | ( | const LogCategory & | category | ) |
Register an existing LogCategory object.
| category | Category to register |
| LogCategory Log::Logger::registerCategory | ( | const QString & | name | ) |
Register a new log category by name.
| name | Category name string |
| void Log::Logger::removeConsumer | ( | LogConsumer * | consumer | ) |
Remove a previously added log consumer.
| consumer | Consumer to remove |
| void Log::Logger::rotateLog | ( | const QString & | newFileName | ) |
Rotate the log to a new file path.
| newFileName | Path to the new log file |
| void Log::Logger::setCategoryLevel | ( | const QString & | name, |
| LogLevel | level | ||
| ) |
Override the log level for a specific category.
| name | Category name |
| level | Level to apply to this category |
| void Log::Logger::setFilename | ( | const QString & | filename | ) |
Set the log file path and reopen the file.
| filename | Path to the output log file |
|
inline |
Set the output flags, replacing any existing flags.
| flags | New OutputFlags bitmask |
Definition at line 129 of file log.h.
References Log::flags().
| void Log::Logger::setIdentity | ( | const QString & | value | ) |
Set the syslog identity string.
| value | Identity string used in syslog output |
|
inline |