From 3d7828faaa7dc5749f8217be9cc9094f5ebcc200 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Tue, 14 Feb 2023 19:07:29 +0100 Subject: [PATCH] Fix tool behaviour for disabled platform logging Now consistent with what libdlog does. It could be extracted to a unified function, but that is not in the scope of this patch. Change-Id: Ifec204ceaae6aa852c62e437f779c2ba9bda1494 --- src/log-redirect-stdout/internal.c | 5 +++-- src/logctl/logctl.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/log-redirect-stdout/internal.c b/src/log-redirect-stdout/internal.c index 94e3c73..f064bac 100644 --- a/src/log-redirect-stdout/internal.c +++ b/src/log-redirect-stdout/internal.c @@ -138,8 +138,9 @@ int setup_single_unstructed(log_id_t buffer, const char *tag, log_priority prio, if (r < 0) return r; - // This matches what log.c does. - bool plog = buffer == LOG_ID_APPS ? true : log_config_get_boolean(&config, "plog", true); + // This matches what log.c does. (FIXME: extract to a unified function) + bool limiter_apply_to_all_buffers = log_config_get_boolean(&config, "limiter_apply_to_all_buffers", false); + bool plog = (buffer != LOG_ID_APPS || limiter_apply_to_all_buffers) ? log_config_get_boolean(&config, "plog", true) : true; char key[MAX_CONF_KEY_LEN]; r = snprintf(key, sizeof key, "enable_%s", log_name_by_id(buffer)); if (r < 0) diff --git a/src/logctl/logctl.c b/src/logctl/logctl.c index 5b49499..c07ec6f 100644 --- a/src/logctl/logctl.c +++ b/src/logctl/logctl.c @@ -746,6 +746,7 @@ int handle_dump(const struct parsed_params *params, const char *config_path, str printf("\nLogging buffer status:\n"); const bool plog_default = log_config_get_boolean(conf, "plog", true); + const bool limiter_apply_to_all_buffers = log_config_get_boolean(conf, "limiter_apply_to_all_buffers", false); for (int i = 0; i < LOG_ID_MAX; ++i) { char key[MAX_CONF_KEY_LEN]; ret = snprintf(key, sizeof key, "enable_%s", log_name_by_id((log_id_t)i)); @@ -756,7 +757,7 @@ int handle_dump(const struct parsed_params *params, const char *config_path, str ret = (is_pipe ? get_stdout_one_pipe : get_stdout_one_nonpipe)(i, conf, &stdout_enabled); printf("* %s (regular): %s\n" , log_name_by_id((log_id_t)i) - , log_config_get_boolean(conf, key, i == LOG_ID_APPS ? plog_default : true) ? "ENABLED" : "DISABLED" + , log_config_get_boolean(conf, key, (i != LOG_ID_APPS || limiter_apply_to_all_buffers) ? plog_default : true) ? "ENABLED" : "DISABLED" ); printf("* %s (stdout): %s\n" , log_name_by_id((log_id_t)i) -- 2.7.4