Kanzi Engine API
log.hpp File Reference

Macros

#define kzLog(logger, level, category, message)
 Use the kzLog macro to write log messages using a custom logger. More...
 
#define kzLogDebug(message)
 To write debug log messages with the Default Logger, use kzLogDebug macro. More...
 
#define kzLogError(category, message)
 To write error log messages with the Default Logger, use kzLogError macro. More...
 
#define kzLogInfo(category, message)
 To write info log messages with the Default Logger, use kzLogInfo macro. More...
 
#define kzLogTrace(category, message)
 To write trace log messages with the Default Logger, use kzLogTrace macro. More...
 
#define kzLogWarning(category, message)
 To write warning log messages with the Default Logger, use kzLogWarning macro. More...
 

Detailed Description

Logging subsystem

The Logging subsystem is responsible for writing messages to the log. To write log messages, use the Logging macros provided by the subsystem.

To filter log messages at compile time, use log levels and log categories. See Classifying and filtering log messages.

You can write both scalar values and formatted messages to the log. See Log message formatting.

Classifying and filtering log messages

Use log levels to classify log messages based on the severity of the information that they contain. For example, to log critical problems, which occur during application execution, use the error log level KZ_LOG_LEVEL_ERROR. To log normal application activity, use the info log level KZ_LOG_LEVEL_INFO. See Log Level.

Use log categories to group messages that contain information about the same functionality. For example, to log messages related to the rendering engine activity, you can create the "Engine" log category. To group messages related to kzb file loading, you can create the "kzb loading" log category. To learn how to create log categories, see Log category.

Log message filtering is implemented in Logging macros. Kanzi filters log messages at compile time using the log levels and log categories that you assign to the messages. The preprocessor removes the call to the logging macro, if you disable the log level or category assigned to the message in that macro call. Otherwise, the macro is replaced with the code that writes the message to the log. To learn how to enable and disable log levels and categories, see Log Level and Log category.

Note
Do not use application critical code in the logging macro calls. If you place application critical code as an argument to the logging macro call, and during compilation you disable the log level or the log category assigned to the message in the call, the preprocessor removes the logging macro call together with the application critical code.

Examples

This example shows how you can filter log messages:

This example shows the danger of using application critical code in a call to the logging macro: