logging: Ensure constant side effects of log API
When log API is used it should give the same side effect when enabled or disabled e.g. LOG_INF(%d,cnt++) should always increment cnt. Before this change cnt would be incremented twice when log enabled and never incremented when log was disabled. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
d731e539ce
commit
77b44df86a
1 changed files with 17 additions and 12 deletions
|
@ -175,8 +175,13 @@ extern "C" {
|
|||
.source_id = _id, \
|
||||
.domain_id = CONFIG_LOG_DOMAIN_ID \
|
||||
}; \
|
||||
log_printf_arg_checker(__VA_ARGS__); \
|
||||
__LOG_INTERNAL(src_level, __VA_ARGS__); \
|
||||
} else { \
|
||||
/* arg checker evaluated when log is filtered out \
|
||||
* to ensure that __VA_ARGS__ are evaluated only \
|
||||
* once giving always same side effects. \
|
||||
*/ \
|
||||
log_printf_arg_checker(__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue