Handles custom message handling and sending of stats/logs to Logstash instance.
More...
#include <LogHandler.h>
Inherits QObject.
Handles custom message handling and sending of stats/logs to Logstash instance.
◆ breakOnMessage()
void LogHandler::breakOnMessage |
( |
const char * |
str | ) |
|
|
static |
Break when a message that contains the specified string is logged.
This is a function intended to be invoked from inside a debugger. It should be of help when it's hard to put a breakpoint on the generating line because it comes from inlined code, or the interesting text is generated at runtime.
Example usage:
static void breakOnMessage(const char *str)
Break when a message that contains the specified string is logged.
Definition: LogHandler.cpp:386
Then the debugger should be triggered as soon as a message containing that string is logged. Backtracking through the call stack should lead back to the source.
- Note
- Support for creating a breakpoint in software is compiler and OS specific. If there's no support for creating a breakpoint on the current compiler/OS, then an abort will be triggered instead.
- Parameters
-
◆ getInstance()
◆ isJournaldAvailable()
bool LogHandler::isJournaldAvailable |
( |
| ) |
const |
Whether Journald is available on this version/system.
Support is available depending on compile options and only on Linux.
- Returns
- true Journald is available
-
false Journald is not available
◆ parseOptions()
bool LogHandler::parseOptions |
( |
const QString & |
options, |
|
|
const QString & |
paramName |
|
) |
| |
Parse logging options.
This parses the logging settings in the environment variable, or from the commandline
- Parameters
-
options | Option list |
paramName | Name of the log option, for error reporting. |
- Returns
- true Option list was parsed successfully
-
false There was an error
◆ printMessage()
QString LogHandler::printMessage |
( |
LogMsgType |
type, |
|
|
const QMessageLogContext & |
context, |
|
|
const QString & |
message |
|
) |
| |
Process a log message.
This writes it to a file, logs it to the console, or sends it to journald.
- Parameters
-
type | Log message type |
context | Context of the log message (source file, line, function) |
message | Log message |
- Returns
- QString The log message's text with added severity and timestamp
◆ setShouldDisplayMilliseconds()
void LogHandler::setShouldDisplayMilliseconds |
( |
bool |
shouldDisplayMilliseconds | ) |
|
Set whether to display timestamps with milliseconds.
- Parameters
-
shouldDisplayMilliseconds | |
◆ setShouldOutputProcessID()
void LogHandler::setShouldOutputProcessID |
( |
bool |
shouldOutputProcessID | ) |
|
Set whether to output the process ID.
- Note
- This has no effect when logging with journald, the PID is always logged
- Parameters
-
shouldOutputProcessID | Whether to output the PID |
◆ setShouldOutputThreadID()
void LogHandler::setShouldOutputThreadID |
( |
bool |
shouldOutputThreadID | ) |
|
Set whether to output the thread ID.
- Parameters
-
◆ setShouldUseJournald()
void LogHandler::setShouldUseJournald |
( |
bool |
shouldUseJournald | ) |
|
Set whether to use Journald, if it's available.
- Parameters
-
shouldUseJournald | Whether to use journald |
◆ setTargetName()
void LogHandler::setTargetName |
( |
const QString & |
targetName | ) |
|
Set the name of the component that's producing log output.
For instance, "assignment-client", "audio-mixer", etc. Called once before logging begins
- Parameters
-
targetName | the desired target name to output in logs |
◆ verboseMessageHandler()
void LogHandler::verboseMessageHandler |
( |
QtMsgType |
type, |
|
|
const QMessageLogContext & |
context, |
|
|
const QString & |
message |
|
) |
| |
|
static |
A qtMessageHandler that can be hooked up to a target that links to Qt.
Prints various process, message type, and time information
- Parameters
-
type | Log message type |
context | Context of the log message (source file, line, function) |
message | Log message |
The documentation for this class was generated from the following files: