This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgHello Harald Welte, Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/5812
to look at the new patch set (#2).
logging: separate the '<000b>' subsys from filename logging
Do not include the category as hex in the log_set_print_filename() flag, add
separate API to switch that: log_set_print_category_hex().
The default behavior is to still include the hex category at the same place in
the log output, but when calling log_set_print_filename(0) now, the hex
category will now remain, until log_set_print_category_hex(0) is called.
Add VTY command 'logging print category-hex (0|1)'.
Change-Id: Iba03a2b7915853c6dccaf6c393c31405320538b4
---
M include/osmocom/core/logging.h
M src/logging.c
M src/vty/logging_vty.c
3 files changed, 39 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/12/5812/2
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 1e809d0..f68991e 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -301,6 +301,8 @@
/* Should the log level be printed? */
bool print_level;
+ /* Should we print the subsys in hex like '<000b>'? */
+ bool print_category_hex;
};
/* use the above macros */
@@ -323,6 +325,7 @@
void log_set_print_timestamp(struct log_target *target, int);
void log_set_print_filename(struct log_target *target, int);
void log_set_print_category(struct log_target *target, int);
+void log_set_print_category_hex(struct log_target *target, int);
void log_set_print_level(struct log_target *target, int);
void log_set_log_level(struct log_target *target, int log_level);
void log_parse_category_mask(struct log_target *target, const char* mask);
diff --git a/src/logging.c b/src/logging.c
index e6e09e0..650598f 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -385,9 +385,14 @@
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);
}
+ if (target->print_category_hex) {
+ ret = snprintf(buf + offset, rem, "<%4.4x> ", subsys);
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+ }
if (target->print_filename) {
- ret = snprintf(buf + offset, rem, "<%4.4x> %s:%d ",
- subsys, file, line);
+ ret = snprintf(buf + offset, rem, "%s:%d ", file, line);
if (ret < 0)
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);
@@ -641,6 +646,15 @@
target->print_category = print_category;
}
+/*! Enable or disable printing of the category number in hex ('<000b>').
+ * \param[in] target Log target to be affected.
+ * \param[in] print_category_hex Enable (1) or disable (0) hex category.
+ */
+void log_set_print_category_hex(struct log_target *target, int print_category_hex)
+{
+ target->print_category_hex = print_category_hex;
+}
+
/*! Enable or disable printing of the log level name.
* \param[in] target Log target to be affected
* \param[in] print_catname Enable (1) or disable (0) filenames
@@ -724,6 +738,7 @@
target->use_color = 1;
target->print_timestamp = 0;
target->print_filename = 1;
+ target->print_category_hex = true;
/* global log level */
target->loglevel = 0;
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 5914822..fd76d04 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -203,6 +203,23 @@
return CMD_SUCCESS;
}
+DEFUN(logging_prnt_cat_hex,
+ logging_prnt_cat_hex_cmd,
+ "logging print category-hex (0|1)",
+ LOGGING_STR "Log output settings\n"
+ "Configure log message\n"
+ "Don't prefix each log message\n"
+ "Prefix each log message with category/subsystem nr in hex ('<000b>')\n")
+{
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+
+ if (!tgt)
+ return CMD_WARNING;
+
+ log_set_print_category_hex(tgt, atoi(argv[0]));
+ return CMD_SUCCESS;
+}
+
DEFUN(logging_prnt_level,
logging_prnt_level_cmd,
"logging print level (0|1)",
@@ -802,6 +819,7 @@
install_element_ve(&logging_prnt_timestamp_cmd);
install_element_ve(&logging_prnt_ext_timestamp_cmd);
install_element_ve(&logging_prnt_cat_cmd);
+ install_element_ve(&logging_prnt_cat_hex_cmd);
install_element_ve(&logging_prnt_level_cmd);
install_element_ve(&logging_set_category_mask_cmd);
install_element_ve(&logging_set_category_mask_old_cmd);
@@ -819,6 +837,7 @@
install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd);
install_element(CFG_LOG_NODE, &logging_prnt_ext_timestamp_cmd);
install_element(CFG_LOG_NODE, &logging_prnt_cat_cmd);
+ install_element(CFG_LOG_NODE, &logging_prnt_cat_hex_cmd);
install_element(CFG_LOG_NODE, &logging_prnt_level_cmd);
install_element(CFG_LOG_NODE, &logging_level_cmd);
--
To view, visit https://gerrit.osmocom.org/5812
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iba03a2b7915853c6dccaf6c393c31405320538b4
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>