CuteHMI - CuteHMI (CuteHMI.2)
Logging macros

Logging macros. More...

Macros

#define CUTEHMI_DEBUG(EXPR)   qCDebug(loggingCategory()).nospace().noquote() << EXPR
 
#define CUTEHMI_INFO(EXPR)   qCInfo(loggingCategory()).nospace().noquote() << EXPR
 
#define CUTEHMI_WARNING(EXPR)   qCWarning(loggingCategory()).nospace().noquote() << EXPR
 
#define CUTEHMI_CRITICAL(EXPR)   qCCritical(loggingCategory()).nospace().noquote() << EXPR
 
#define CUTEHMI_DIE(...)   QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, loggingCategory().categoryName()).fatal(__VA_ARGS__)
 
#define CUTEHMI_ASSERT(EXPR, MSG)   Q_ASSERT_X(EXPR, __FILE__, MSG)
 

Detailed Description

Logging macros.

Convenient macros to log messages with Qt logging categories. These macros can be used by other modules providing that they implement loggingCategory() function in their own namespace. This function should return QLoggingCategory object, which is declared and defined with Q_DECLARE_LOGGING_CATEGORY and Q_LOGGING_CATEGORY macros, as described in Qt documentation. Macros are corresponding to Qt debug streams.

There's no CUTEHMI_FATAL, because Qt (5.12) does not provide QDebug output stream for fatal errors. Instead CUTEHMI_DIE macro can be used. Unlike the other logging macros CUTEHMI_DIE does not wrap QDebug output stream, so a formatted string should be passed as macro argument (see QMessageLogger::fatal()).

Macro Definition Documentation

◆ CUTEHMI_ASSERT

#define CUTEHMI_ASSERT (   EXPR,
  MSG 
)    Q_ASSERT_X(EXPR, __FILE__, MSG)

Assert.

Parameters
EXPRassert expression
MSGmessage printed in case of assertion failure.

◆ CUTEHMI_CRITICAL

#define CUTEHMI_CRITICAL (   EXPR)    qCCritical(loggingCategory()).nospace().noquote() << EXPR

Print critical message.

Parameters
EXPRmessage (can be composed of stream expression).

◆ CUTEHMI_DEBUG

#define CUTEHMI_DEBUG (   EXPR)    qCDebug(loggingCategory()).nospace().noquote() << EXPR

Print debug message.

Parameters
EXPRmessage (can be composed of stream expression).

◆ CUTEHMI_DIE

#define CUTEHMI_DIE (   ...)    QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, loggingCategory().categoryName()).fatal(__VA_ARGS__)

Print fatal message and abort or exit program.

Parameters
...fatal message and optional list of arguments interpreted by message format string.

◆ CUTEHMI_INFO

#define CUTEHMI_INFO (   EXPR)    qCInfo(loggingCategory()).nospace().noquote() << EXPR

Print informative message.

Parameters
EXPRmessage (can be composed of stream expression).

◆ CUTEHMI_WARNING

#define CUTEHMI_WARNING (   EXPR)    qCWarning(loggingCategory()).nospace().noquote() << EXPR

Print warning.

Parameters
EXPRmessage (can be composed of stream expression).