Fix tool behaviour for disabled platform logging 94/288294/1
authorMichal Bloch <m.bloch@samsung.com>
Tue, 14 Feb 2023 18:07:29 +0000 (19:07 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Tue, 14 Feb 2023 18:09:39 +0000 (19:09 +0100)
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
src/logctl/logctl.c

index 94e3c73..f064bac 100644 (file)
@@ -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)
index 5b49499..c07ec6f 100644 (file)
@@ -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)