QMessageLogger Class

The QMessageLogger class generates log messages. 更多...

头: #include <QMessageLogger>
qmake: QT += core
Since: Qt 5.0

公共类型

typedef CategoryFunction

公共函数

QMessageLogger ()
QMessageLogger (const char * file , int line , const char * function )
QMessageLogger (const char * file , int line , const char * function , const char * category )
void critical (const char * msg , ... ) const
void critical (const QLoggingCategory & cat , const char * msg , ... ) const
void critical (CategoryFunction catFunc , const char * msg , ... ) const
QDebug critical () const
QDebug critical (const QLoggingCategory & cat ) const
QDebug critical (CategoryFunction catFunc ) const
void debug (const char * msg , ... ) const
void debug (const QLoggingCategory & cat , const char * msg , ... ) const
void debug (CategoryFunction catFunc , const char * msg , ... ) const
QDebug debug () const
QDebug debug (const QLoggingCategory & cat ) const
QDebug debug (CategoryFunction catFunc ) const
void fatal (const char * msg , ... ) const
void info (const char * msg , ... ) const
void info (const QLoggingCategory & cat , const char * msg , ... ) const
void info (CategoryFunction catFunc , const char * msg , ... ) const
QDebug info () const
QDebug info (const QLoggingCategory & cat ) const
QDebug info (CategoryFunction catFunc ) const
void warning (const char * msg , ... ) const
void warning (const QLoggingCategory & cat , const char * msg , ... ) const
void warning (CategoryFunction catFunc , const char * msg , ... ) const
QDebug warning () const
QDebug warning (const QLoggingCategory & cat ) const
QDebug warning (CategoryFunction catFunc ) const

详细描述

The QMessageLogger class generates log messages.

QMessageLogger is used to generate messages for the Qt logging framework. Usually one uses it through qDebug (), qInfo (), qWarning (), qCritical ,或 qFatal () functions, which are actually macros: For example qDebug () expands to QMessageLogger (__FILE__, __LINE__, Q_FUNC_INFO ). debug () for debug builds, and QMessageLogger (0, 0, 0). debug () for release builds.

One example of direct use is to forward errors that stem from a scripting language, e.g. QML:

    void statusChanged(QDeclarativeComponent::Status status) {
        if (status == QDeclarativeComponent::Error) {
            foreach (const QDeclarativeError &error, component->errors()) {
                const QByteArray file = error.url().toEncoded();
                QMessageLogger(file.constData(), error.line(), 0).debug() << error.description();
            }
        }
    }
					

另请参阅 QMessageLogContext , qDebug (), qInfo (), qWarning (), qCritical (),和 qFatal ().

成员类型文档编制

typedef QMessageLogger:: CategoryFunction

这是采用以下签名的函数指针的 typedef:

    const QLoggingCategory &category();
					

A function which this signature is generated by Q_DECLARE_LOGGING_CATEGORY , Q_LOGGING_CATEGORY .

This typedef was introduced in Qt 5.3.

成员函数文档编制

QMessageLogger:: QMessageLogger ()

Constructs a default QMessageLogger . See the other constructors to specify context information.

QMessageLogger:: QMessageLogger (const char * file , int line , const char * function )

构造 QMessageLogger to record log messages for file at line in function . The is equivalent to QMessageLogger (file, line, function, "default")

QMessageLogger:: QMessageLogger (const char * file , int line , const char * function , const char * category )

构造 QMessageLogger to record category messages for file at line in function .

void QMessageLogger:: critical (const char * msg , ... ) const

Logs a critical message specified with format msg . Additional parameters, specified by msg , may be used.

另请参阅 qCritical ().

void QMessageLogger:: critical (const QLoggingCategory & cat , const char * msg , ... ) const

Logs a critical message specified with format msg for the context cat . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.3 引入。

另请参阅 qCCritical ().

void QMessageLogger:: critical ( CategoryFunction catFunc , const char * msg , ... ) const

Logs a critical message specified with format msg for the context returned by catFunc . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.3 引入。

另请参阅 qCCritical ().

QDebug QMessageLogger:: critical () const

Logs a critical message using a QDebug stream

另请参阅 qCritical () 和 QDebug .

QDebug QMessageLogger:: critical (const QLoggingCategory & cat ) const

Logs a critical message into category cat 使用 QDebug stream.

该函数在 Qt 5.3 引入。

另请参阅 qCCritical () 和 QDebug .

QDebug QMessageLogger:: critical ( CategoryFunction catFunc ) const

Logs a critical message into category returned by catFunc 使用 QDebug stream.

该函数在 Qt 5.3 引入。

另请参阅 qCCritical () 和 QDebug .

void QMessageLogger:: debug (const char * msg , ... ) const

Logs a debug message specified with format msg . Additional parameters, specified by msg , may be used.

另请参阅 qDebug ().

void QMessageLogger:: debug (const QLoggingCategory & cat , const char * msg , ... ) const

Logs a debug message specified with format msg for the context cat . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.3 引入。

另请参阅 qCDebug ().

void QMessageLogger:: debug ( CategoryFunction catFunc , const char * msg , ... ) const

Logs a debug message specified with format msg for the context returned by catFunc . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.3 引入。

另请参阅 qCDebug ().

QDebug QMessageLogger:: debug () const

Logs a debug message using a QDebug stream

另请参阅 qDebug () 和 QDebug .

QDebug QMessageLogger:: debug (const QLoggingCategory & cat ) const

Logs a debug message into category cat 使用 QDebug stream.

该函数在 Qt 5.3 引入。

另请参阅 qCDebug () 和 QDebug .

QDebug QMessageLogger:: debug ( CategoryFunction catFunc ) const

Logs a debug message into category returned by catFunc 使用 QDebug stream.

该函数在 Qt 5.3 引入。

另请参阅 qCDebug () 和 QDebug .

void QMessageLogger:: fatal (const char * msg , ... ) const

Logs a fatal message specified with format msg . Additional parameters, specified by msg , may be used.

另请参阅 qFatal ().

void QMessageLogger:: info (const char * msg , ... ) const

Logs an informational message specified with format msg . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.5 引入。

另请参阅 qInfo ().

void QMessageLogger:: info (const QLoggingCategory & cat , const char * msg , ... ) const

Logs an informational message specified with format msg for the context cat . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.5 引入。

另请参阅 qCInfo ().

void QMessageLogger:: info ( CategoryFunction catFunc , const char * msg , ... ) const

Logs an informational message specified with format msg for the context returned by catFunc . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.5 引入。

另请参阅 qCInfo ().

QDebug QMessageLogger:: info () const

Logs an informational message using a QDebug stream.

该函数在 Qt 5.5 引入。

另请参阅 qInfo () 和 QDebug .

QDebug QMessageLogger:: info (const QLoggingCategory & cat ) const

Logs an informational message into the category cat 使用 QDebug stream.

该函数在 Qt 5.5 引入。

另请参阅 qCInfo () 和 QDebug .

QDebug QMessageLogger:: info ( CategoryFunction catFunc ) const

Logs an informational message into category returned by catFunc 使用 QDebug stream.

该函数在 Qt 5.5 引入。

另请参阅 qCInfo () 和 QDebug .

void QMessageLogger:: warning (const char * msg , ... ) const

Logs a warning message specified with format msg . Additional parameters, specified by msg , may be used.

另请参阅 qWarning ().

void QMessageLogger:: warning (const QLoggingCategory & cat , const char * msg , ... ) const

Logs a warning message specified with format msg for the context cat . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.3 引入。

另请参阅 qCWarning ().

void QMessageLogger:: warning ( CategoryFunction catFunc , const char * msg , ... ) const

Logs a warning message specified with format msg for the context returned by catFunc . Additional parameters, specified by msg , may be used.

该函数在 Qt 5.3 引入。

另请参阅 qCWarning ().

QDebug QMessageLogger:: warning () const

Logs a warning message using a QDebug stream

另请参阅 qWarning () 和 QDebug .

QDebug QMessageLogger:: warning (const QLoggingCategory & cat ) const

Logs a warning message into category cat 使用 QDebug stream.

另请参阅 qCWarning () 和 QDebug .

QDebug QMessageLogger:: warning ( CategoryFunction catFunc ) const

Logs a warning message into category returned by catFunc 使用 QDebug stream.

该函数在 Qt 5.3 引入。

另请参阅 qCWarning () 和 QDebug .