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.orgNeels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/10886 Change subject: logging: define lower-case loglevel value_string[] ...................................................................... logging: define lower-case loglevel value_string[] Instead of constantly converting logging level strings to lowercase representation during VTY interaction, just define loglevel_strs_lower[] and use those. I'm not defining a log_level_str_lower() function to wrap get_value_string(), because I already know that a later patch will switch to using get_value_string_or_null(). Change-Id: Ie55d732281bdf74324e1dd7f8a2ba91d11409851 --- M include/osmocom/core/logging_internal.h M src/logging.c M src/vty/logging_vty.c 3 files changed, 15 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/10886/1 diff --git a/include/osmocom/core/logging_internal.h b/include/osmocom/core/logging_internal.h index 55b1bbd..96b80a3 100644 --- a/include/osmocom/core/logging_internal.h +++ b/include/osmocom/core/logging_internal.h @@ -9,6 +9,8 @@ extern void *tall_log_ctx; extern const struct log_info *osmo_log_info; +extern const struct value_string loglevel_strs_lower[]; + void assert_loginfo(const char *src); /*! @} */ diff --git a/src/logging.c b/src/logging.c index 67470a5..159838c 100644 --- a/src/logging.c +++ b/src/logging.c @@ -72,6 +72,16 @@ { 0, NULL }, }; +/*! human readable string for each log level, lower case */ +const struct value_string loglevel_strs_lower[] = { + { LOGL_DEBUG, "debug" }, + { LOGL_INFO, "info" }, + { LOGL_NOTICE, "notice" }, + { LOGL_ERROR, "error" }, + { LOGL_FATAL, "fatal" }, + { 0, NULL }, +}; + #define INT2IDX(x) (-1*(x)-1) static const struct log_info_cat internal_cat[OSMO_NUM_DLIB] = { [INT2IDX(DLGLOBAL)] = { /* -1 becomes 0 */ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6758dd2..d0a9421 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -861,9 +861,9 @@ get_value_string(logging_print_file_args, tgt->print_filename2), VTY_NEWLINE); - /* stupid old osmo logging API uses uppercase strings... */ if (tgt->loglevel) - vty_out(vty, " logging level all %s%s", osmo_str_tolower(log_level_str(tgt->loglevel)), + vty_out(vty, " logging level all %s%s", + get_value_string(loglevel_strs_lower, tgt->loglevel), VTY_NEWLINE); for (i = 0; i < osmo_log_info->num_cat; i++) { @@ -875,7 +875,7 @@ /* stupid old osmo logging API uses uppercase strings... */ vty_out(vty, " logging level %s", osmo_str_tolower(osmo_log_info->cat[i].name+1)); - vty_out(vty, " %s%s", osmo_str_tolower(log_level_str(cat->loglevel)), VTY_NEWLINE); + vty_out(vty, " %s%s", get_value_string(loglevel_strs_lower, cat->loglevel), VTY_NEWLINE); } return 1; -- To view, visit https://gerrit.osmocom.org/10886 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ie55d732281bdf74324e1dd7f8a2ba91d11409851 Gerrit-Change-Number: 10886 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180912/26ba7d7c/attachment.htm>