QXmppLogger Class

The QXmppLogger class represents a sink for logging messages. More...

Header: #include <QXmppLogger.h>

Public Types

enum ColorMode { ColorOff, ColorOn, ColorAuto }
enum LoggingType { NoLogging, FileLogging, StdoutLogging, SignalLogging }
enum MessageType { NoMessage, DebugMessage, InformationMessage, WarningMessage, ReceivedMessage, …, AnyMessage }
flags MessageTypes

Properties

Public Functions

QXmppLogger(QObject *parent = nullptr)
(since QXmpp 1.16) QXmppLogger::ColorMode colorMode() const
(since QXmpp 1.16) void enablePrettyXml(bool enable = true)
(since QXmpp 1.17) bool filterStreamManagementAcks() const
QString logFilePath()
QXmppLogger::LoggingType loggingType()
QXmppLogger::MessageTypes messageTypes()
(since QXmpp 1.16) bool prettyXml() const
(since QXmpp 1.16) void setColorMode(QXmppLogger::ColorMode mode)
(since QXmpp 1.17) void setFilterStreamManagementAcks(bool enable)
void setLogFilePath(const QString &path)
void setLoggingType(QXmppLogger::LoggingType type)
void setMessageTypes(QXmppLogger::MessageTypes types)
(since QXmpp 1.16) void setPrettyXml(bool enable)

Public Slots

void log(QXmppLogger::MessageType type, const QString &text)
void reopen()
virtual void setGauge(const QString &gauge, double value)
virtual void updateCounter(const QString &counter, qint64 amount)

Signals

void colorModeChanged()
(since QXmpp 1.7) void logFilePathChanged()
(since QXmpp 1.7) void loggingTypeChanged()
void message(QXmppLogger::MessageType type, const QString &text)
(since QXmpp 1.7) void messageTypesChanged()
void prettyXmlChanged()

Static Public Members

QXmppLogger *getLogger()

Detailed Description

Member Type Documentation

enum QXmppLogger::ColorMode

Controls ANSI color output for pretty-printed XML.

ConstantValueDescription
QXmppLogger::ColorOff0Never emit color escapes
QXmppLogger::ColorOn1Always emit color escapes
QXmppLogger::ColorAuto2Emit colors when loggingType is StdoutLogging and stdout is a TTY

enum QXmppLogger::LoggingType

This enum describes how log message are handled.

ConstantValueDescription
QXmppLogger::NoLogging0Log messages are discarded.
QXmppLogger::FileLogging1Log messages are written to a file.
QXmppLogger::StdoutLogging2Log messages are written to the standard output.
QXmppLogger::SignalLogging4Log messages are emitted as a signal.

enum QXmppLogger::MessageType
flags QXmppLogger::MessageTypes

This enum describes a type of log message.

ConstantValueDescription
QXmppLogger::NoMessage0No message type.
QXmppLogger::DebugMessage1Debugging message.
QXmppLogger::InformationMessage2Informational message.
QXmppLogger::WarningMessage4Warning message.
QXmppLogger::ReceivedMessage8Message received from server.
QXmppLogger::SentMessage16Message sent to server.
QXmppLogger::AnyMessage31Any message type.

The MessageTypes type is a typedef for QFlags<MessageType>. It stores an OR combination of MessageType values.

Property Documentation

colorMode : ColorMode

How to decide whether to use ANSI color escapes for pretty XML

Access functions:

QXmppLogger::ColorMode colorMode() const
void setColorMode(QXmppLogger::ColorMode mode)

Notifier signal:

void colorModeChanged()

logFilePath : QString

The path to which logging messages should be written

Access functions:

QString logFilePath()
void setLogFilePath(const QString &path)

Notifier signal:

loggingType : LoggingType

The handler for logging messages

Access functions:

QXmppLogger::LoggingType loggingType()
void setLoggingType(QXmppLogger::LoggingType type)

Notifier signal:

messageTypes : MessageTypes

The types of messages to log

Access functions:

QXmppLogger::MessageTypes messageTypes()
void setMessageTypes(QXmppLogger::MessageTypes types)

Notifier signal:

prettyXml : bool

Whether to pretty-print Sent/Received XML stanzas with indentation

Access functions:

bool prettyXml() const
void setPrettyXml(bool enable)

Notifier signal:

void prettyXmlChanged()

Member Function Documentation

QXmppLogger::QXmppLogger(QObject *parent = nullptr)

Constructs a new QXmppLogger with parent.

[since QXmpp 1.16] QXmppLogger::ColorMode QXmppLogger::colorMode() const

Returns the current ANSI color mode for pretty-printed XML.

Note: Getter function for property colorMode.

This function was introduced in QXmpp 1.16.

See also setColorMode().

[since QXmpp 1.16] void QXmppLogger::enablePrettyXml(bool enable = true)

Enables (enable) pretty-printing of Sent/Received XML stanzas and sets ColorAuto so ANSI escapes appear on a TTY.

Equivalent to calling setPrettyXml(enable) and, if enabling, setColorMode(ColorAuto).

This function was introduced in QXmpp 1.16.

[since QXmpp 1.17] bool QXmppLogger::filterStreamManagementAcks() const

Returns whether XEP-0198: Stream Management ack stanzas (<r/> and <a/>) are filtered out of Sent/Received logging.

These tiny stanzas are exchanged very frequently and otherwise flood the log. Enabled by default.

This function was introduced in QXmpp 1.17.

See also setFilterStreamManagementAcks().

[static] QXmppLogger *QXmppLogger::getLogger()

Returns the default logger.

[slot] void QXmppLogger::log(QXmppLogger::MessageType type, const QString &text)

Add a logging message.

type and text.

QString QXmppLogger::logFilePath()

Returns the path to which logging messages should be written.

Note: Getter function for property logFilePath.

See also setLogFilePath() and loggingType().

[signal, since QXmpp 1.7] void QXmppLogger::logFilePathChanged()

Emitted when the log file path has been changed.

Note: Notifier signal for property logFilePath.

This function was introduced in QXmpp 1.7.

QXmppLogger::LoggingType QXmppLogger::loggingType()

Returns the handler for logging messages.

Note: Getter function for property loggingType.

See also setLoggingType().

[signal, since QXmpp 1.7] void QXmppLogger::loggingTypeChanged()

Emitted when the logging type has been changed.

Note: Notifier signal for property loggingType.

This function was introduced in QXmpp 1.7.

[signal] void QXmppLogger::message(QXmppLogger::MessageType type, const QString &text)

This signal is emitted whenever a log message is received.

type and text.

QXmppLogger::MessageTypes QXmppLogger::messageTypes()

Returns the types of messages to log.

Note: Getter function for property messageTypes.

See also setMessageTypes().

[signal, since QXmpp 1.7] void QXmppLogger::messageTypesChanged()

Emitted when the message types have been changed.

Note: Notifier signal for property messageTypes.

This function was introduced in QXmpp 1.7.

[since QXmpp 1.16] bool QXmppLogger::prettyXml() const

Returns whether Sent/Received XML stanzas should be pretty-printed.

Note: Getter function for property prettyXml.

This function was introduced in QXmpp 1.16.

See also setPrettyXml().

[slot] void QXmppLogger::reopen()

If logging to a file, causes the file to be re-opened.

[since QXmpp 1.16] void QXmppLogger::setColorMode(QXmppLogger::ColorMode mode)

Sets the ANSI color mode for pretty-printed XML. See ColorMode.

Note: Setter function for property colorMode.

This function was introduced in QXmpp 1.16.

See also colorMode().

[since QXmpp 1.17] void QXmppLogger::setFilterStreamManagementAcks(bool enable)

Sets whether XEP-0198: Stream Management ack stanzas (<r/> and <a/>) are filtered out of Sent/Received logging (enable).

This function was introduced in QXmpp 1.17.

See also filterStreamManagementAcks().

[virtual slot] void QXmppLogger::setGauge(const QString &gauge, double value)

Sets the given gauge to value.

NOTE: the base implementation does nothing.

void QXmppLogger::setLogFilePath(const QString &path)

Sets the path to which logging messages should be written to path.

Note: Setter function for property logFilePath.

See also logFilePath() and setLoggingType().

void QXmppLogger::setLoggingType(QXmppLogger::LoggingType type)

Sets the handler for logging messages.

type.

Note: Setter function for property loggingType.

See also loggingType().

void QXmppLogger::setMessageTypes(QXmppLogger::MessageTypes types)

Sets the types of messages to log.

Note: Setter function for property messageTypes.

See also messageTypes().

[since QXmpp 1.16] void QXmppLogger::setPrettyXml(bool enable)

Sets whether Sent/Received XML stanzas should be pretty-printed (enable).

Note: Setter function for property prettyXml.

This function was introduced in QXmpp 1.16.

See also prettyXml().

[virtual slot] void QXmppLogger::updateCounter(const QString &counter, qint64 amount)

Updates the given counter by amount.

NOTE: the base implementation does nothing.