Anjay Lite
Loading...
Searching...
No Matches
log.h File Reference

Logging API for Anjay Lite. More...

#include <anj/init.h>
#include <stdio.h>
#include <anj/compat/log_impl_decls.h>
#include <anj/utils.h>

Go to the source code of this file.

Macros

#define anj_log(Module, LogLevel, ...)
 
#define ANJ_LOG_DISPOSABLE(Arg)   ANJ_LOG_DISPOSABLE_IMPL(Arg)
 

Detailed Description

Logging API for Anjay Lite.

Provides macros for emitting log messages with compile-time filtering and configurable backends.

Macro Definition Documentation

◆ anj_log

#define anj_log (   Module,
  LogLevel,
  ... 
)
Value:
((void) (ANJ_LOG_IF_ALLOWED(Module, LogLevel, __VA_ARGS__), \
ANJ_LOG_COMPILE_TIME_CHECK(__VA_ARGS__)))

Logs a message.

Log statements are a subject to compile-time filtering. The level of this statement must be equal or higher than the configured level of the module, if defined, or the default level ( ANJ_LOG_LEVEL_DEFAULT ).

anj_log(my_module, L_DEBUG, "Hello %s, %d!", "world", 42);
#define anj_log(Module, LogLevel,...)
Definition log.h:120
Parameters
ModuleName of the module that generates the message, given as a raw token.
LogLevelLog level, specified as a name of anj_log_level_t (other than L_MUTED) with the leading ANJ_LOG_LEVEL_ omitted.

◆ ANJ_LOG_DISPOSABLE

#define ANJ_LOG_DISPOSABLE (   Arg)    ANJ_LOG_DISPOSABLE_IMPL(Arg)

Replaces a string constant with " " if ANJ_LOG_STRIP_CONSTANTS is enabled. This is useful for wrapping constant parts of log messages, to shorten them, and therefore reduce the size of the binary.

anj_log(my_module, L_DEBUG, ANJ_LOG_DISPOSABLE("The result is: ") "%d", 42);
#define ANJ_LOG_DISPOSABLE(Arg)
Definition log.h:145
Note
Provided string constants shall not contain any format specifiers.
Parameters
ArgA string constant to be potentially replaced with " ".