IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QMessageLogger Class

The QMessageLogger class generates log messages.

This class was introduced in Qt 5.0.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QMessageLogger Class

  • Header: QMessageLogger

  • Since: Qt 5.0

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Core)

    target_link_libraries(mytarget PRIVATE Qt6::Core)

  • qmake: QT += core

Detailed Description

QMessageLogger is used to generate messages for the Qt logging framework. Usually one uses it through qDebug(), qInfo(), qWarning(), qCritical, or 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:

 
Sélectionnez
    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();
            }
        }
    }

See Also

Member Type Documentation

 

[since 5.3] QMessageLogger::CategoryFunction

This is a typedef for a pointer to a function with the following signature:

 
Sélectionnez
    const QLoggingCategory &category();

The Q_DECLARE_LOGGING_CATEGORY macro generates a function declaration with this signature, and Q_LOGGING_CATEGORY generates its definition.

This typedef was introduced in Qt 5.3.

Member Function Documentation

 

[constexpr] QMessageLogger::QMessageLogger()

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

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

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

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

Constructs a 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.

See Also

See also qCritical()

[since 5.3] 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.

This function was introduced in Qt 5.3.

See Also

See also qCCritical()

[since 5.3] void QMessageLogger::critical(QMessageLogger::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.

This function was introduced in Qt 5.3.

See Also

See also qCCritical()

QDebug QMessageLogger::critical() const

Logs a critical message using a QDebug stream

See Also

See also qCritical(), QDebug

[since 5.3] QDebug QMessageLogger::critical(const QLoggingCategory &cat) const

Logs a critical message into category cat using a QDebug stream.

This function was introduced in Qt 5.3.

See Also

See also qCCritical(), QDebug

[since 5.3] QDebug QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc) const

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

This function was introduced in Qt 5.3.

See Also

See also 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.

See Also

See also qDebug()

[since 5.3] 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.

This function was introduced in Qt 5.3.

See Also

See also qCDebug()

[since 5.3] void QMessageLogger::debug(QMessageLogger::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.

This function was introduced in Qt 5.3.

See Also

See also qCDebug()

QDebug QMessageLogger::debug() const

Logs a debug message using a QDebug stream

See Also

See also qDebug(), QDebug

[since 5.3] QDebug QMessageLogger::debug(const QLoggingCategory &cat) const

Logs a debug message into category cat using a QDebug stream.

This function was introduced in Qt 5.3.

See Also

See also qCDebug(), QDebug

[since 5.3] QDebug QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc) const

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

This function was introduced in Qt 5.3.

See Also

See also 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.

See Also

See also qFatal()

[since 5.5] void QMessageLogger::info(const char *msg, ...) const

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

This function was introduced in Qt 5.5.

See Also

See also qInfo()

[since 5.5] 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.

This function was introduced in Qt 5.5.

See Also

See also qCInfo()

[since 5.5] void QMessageLogger::info(QMessageLogger::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.

This function was introduced in Qt 5.5.

See Also

See also qCInfo()

[since 5.5] QDebug QMessageLogger::info() const

Logs an informational message using a QDebug stream.

This function was introduced in Qt 5.5.

See Also

See also qInfo(), QDebug

[since 5.5] QDebug QMessageLogger::info(const QLoggingCategory &cat) const

Logs an informational message into the category cat using a QDebug stream.

This function was introduced in Qt 5.5.

See Also

See also qCInfo(), QDebug

[since 5.5] QDebug QMessageLogger::info(QMessageLogger::CategoryFunction catFunc) const

Logs an informational message into category returned by catFunc using a QDebug stream.

This function was introduced in Qt 5.5.

See Also

See also 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.

See Also

See also qWarning()

[since 5.3] 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.

This function was introduced in Qt 5.3.

See Also

See also qCWarning()

[since 5.3] void QMessageLogger::warning(QMessageLogger::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.

This function was introduced in Qt 5.3.

See Also

See also qCWarning()

QDebug QMessageLogger::warning() const

Logs a warning message using a QDebug stream

See Also

See also qWarning(), QDebug

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

Logs a warning message into category cat using a QDebug stream.

See Also

See also qCWarning(), QDebug

[since 5.3] QDebug QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc) const

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

This function was introduced in Qt 5.3.

See Also

See also qCWarning(), QDebug

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+