Guard log_printf in LOG macros with a log level check
So that the format arguments will only be evaluated if the log is enabled by the log level. Allow us to add more expensive logs without impact performance when they are not enabled. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
@@ -98,6 +98,10 @@ void log_set_level(struct log *l, int level) {
|
||||
l->log_level = level;
|
||||
}
|
||||
|
||||
enum log_level log_get_level(const struct log *l) {
|
||||
return l->log_level;
|
||||
}
|
||||
|
||||
attr_printf(4, 5) void log_printf(struct log *l, int level, const char *func,
|
||||
const char *fmt, ...) {
|
||||
assert(level <= LOG_LEVEL_FATAL && level >= 0);
|
||||
|
||||
Reference in New Issue
Block a user