log: Add LOG_SET_PREFIX() macro
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 27 Mar 2023 14:55:17 +0000 (16:55 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 29 Mar 2023 04:00:33 +0000 (13:00 +0900)
commitee2975a9d9ae11e387f1c5af179e2e6b0ef6ada8
tree812fb31f96dcaf612ea19f8e3b193fba7bbae91e
parent09ba6d1a14ba027f2bc4e3426c7dd85db19e720e
log: Add LOG_SET_PREFIX() macro

LOG_SET_PREFIX() sets a logging prefix for the current block. The
prefix is prepended to every logging message in the block, followed
by ": ". If a logging prefix is already configured, it is overridden
for the duration of the block, after which it is restored.

A use case for this macro is when we're operating on an image or
directory (using --root or --image). We can use LOG_SET_PREFIX() to
prefix all logging messages with the directory or image that we're
operating on.
src/basic/log.c
src/basic/log.h
src/test/test-log.c