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:
Krzysztof Chruscinski 2018-07-11 14:31:47 +02:00 committed by Anas Nashif
commit 77b44df86a

View file

@ -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)