aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/logging_vty.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2023-04-22 22:41:33 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-05-07 18:06:47 +0200
commit2a8a76bf65bf3d6c7c03615f41c4575a7e83b807 (patch)
tree1ec22d252280f79f6ebc1b825e542593927a7803 /src/vty/logging_vty.c
parent2816f44fc9dbd9624e4743f1966802be333164c1 (diff)
formalize log subsys stripping for vty
In osmocom, we historically have a leading 'D' in all of our logging subsystem names -- not only in the enum entry name, but also as the string in struct log_info_cat[]. As a result of this, our logging_vty code strips away the first character of each logging subsystem name. In the VTY, we don't enter 'dmain', but only 'main' -- the VTY strips the 'D' from "DMAIN". The intention is to make this stripping behavior optional in a subsequent patch. So far the code to do that is a magic "+ 1" thrown in here and there. Instead, introduce log_subsys_name() and use it where ever logging_vty.c does removal of the leading 'D'. I would have liked to keep this within logging_vty.c, but unfortunately it needs to be public API in logging.h, because of log_parse_category() which also strips leading D and lives in logging.c. Change-Id: I5f81343e8c7b714a4630e64ba654e391435c4244
Diffstat (limited to 'src/vty/logging_vty.c')
-rw-r--r--src/vty/logging_vty.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 678ae686..9f38c141 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -322,8 +322,7 @@ static void add_category_strings(char **cmd_str_p, char **doc_str_p,
for (i = 0; i < categories->num_cat; i++) {
if (categories->cat[i].name == NULL)
continue;
- /* skip the leading 'D' in each category name, hence '+ 1' */
- osmo_str_tolower_buf(buf, sizeof(buf), categories->cat[i].name + 1);
+ osmo_str_tolower_buf(buf, sizeof(buf), log_subsys_name(categories, i));
osmo_talloc_asprintf(tall_log_ctx, *cmd_str_p, "%s%s",
i ? "|" : "", buf);
osmo_talloc_asprintf(tall_log_ctx, *doc_str_p, "%s\n",
@@ -530,7 +529,7 @@ static void vty_print_logtarget(struct vty *vty, const struct log_info *info,
if (!info->cat[i].name)
continue;
vty_out(vty, " %-10s %-10s %-8s %s%s",
- info->cat[i].name+1, log_level_str(cat->loglevel),
+ log_subsys_name(info, i), log_level_str(cat->loglevel),
cat->enabled ? "Enabled" : "Disabled",
info->cat[i].description,
VTY_NEWLINE);
@@ -1095,7 +1094,7 @@ static int config_write_log_single(struct vty *vty, struct log_target *tgt)
if (!osmo_log_info->cat[i].name)
continue;
- osmo_str_tolower_buf(cat_name, sizeof(cat_name), osmo_log_info->cat[i].name + 1);
+ osmo_str_tolower_buf(cat_name, sizeof(cat_name), log_subsys_name(osmo_log_info, i));
level_str = get_value_string_or_null(loglevel_strs, cat->loglevel);
if (!level_str) {