diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-09-10 13:56:03 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2018-09-13 15:46:55 +0000 |
commit | ba0762d6cbcb8204212d28261e71b57bbc9ba5bc (patch) | |
tree | c472642e6017d341edc89bbd365b8da4b1d1e808 /include | |
parent | d79f01e0a610260524e976149d31a5c2d3b83c94 (diff) |
logging vty: rewrite 'logging level' vty cmd generation
Completely drop the implementations of log_vty_command_{str,description}().
These functions have been public API once, marked as deprecated since
c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7 (March 2017). I considered to keep
them, or reduce them to useless stubs, but it is quite silly, really. These
functions are completely and utterly useless outside of libosmocore. Any
program linking these deserves to fail.
Re-implement vty logging level command gen, in logging_vty.c. logging.c is
simply the wrong place for that.
Introduce logging_internal.h to share logging definitions to logging_vty.c
without publishing as API.
Introduce static gen_logging_level_cmd_strs() to compose a list of category
arguments with their descriptions for VTY commands. Use osmo_talloc_asprintf()
instead of the previous error prone and chaotic strlen() counting method.
Do not dynamically generate log level arguments, just keep static strings. We
are super unlikely to ever change the log levels we have.
No changes in logging_vty_test.vty: proves that there is no functional change.
All of this, besides introducing basic sanity, is cosmetic preparation to be
able to re-use the generic command generation code for arbitrary commands with
category or level args (for deprecated and new keywords).
Rationale: I want to hide 'all' and 'everything' from the VTY command
documentation, by means of deprecating. I first tried to simply define a
deprecated 'logging level CAT everything' command:
logging level (all|rsl|rr|...) (debug|info|notice|error|fatal)
logging level CAT everything # <- deprecated and hidden
But unfortunately, command matching doesn't work as intended when the CAT
argument reflects a valid category; I want it to invoke the deprecated function
as soon as the 'everything' keyword follows, but it stays stuck to the "valid"
command when the category argument matches an explicit keyword in that list,
and will throw an error on the following 'everything' keyword. I.e.:
logging level rsl everything
% Unknown command # <-- leads to config file parse error
logging level unknown_string everything
% Ignoring deprecated 'everything' # <-- works only for invalid categories
So I need to define 'everything' separately, again with a list of each valid
category instead of a generic CAT arg.
Change-Id: I3b083f27e3d751ccec258880ae7676e9af959a63
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 5 | ||||
-rw-r--r-- | include/osmocom/core/logging.h | 4 | ||||
-rw-r--r-- | include/osmocom/core/logging_internal.h | 14 |
3 files changed, 18 insertions, 5 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index ef8ec656..19695d1b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -152,7 +152,10 @@ nobase_include_HEADERS += \ endif noinst_HEADERS = \ - osmocom/gsm/kasumi.h osmocom/gsm/gea.h + osmocom/gsm/kasumi.h \ + osmocom/gsm/gea.h \ + osmocom/core/logging_internal.h \ + $(NULL) osmocom/core/bit%gen.h: osmocom/core/bitXXgen.h.tpl $(AM_V_GEN)$(MKDIR_P) $(dir $@) diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index c60143d9..295e5a85 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -374,10 +374,6 @@ int log_targets_reopen(void); void log_add_target(struct log_target *target); void log_del_target(struct log_target *target); -/* Generate command string for VTY use */ -const char *log_vty_command_string() OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE; -const char *log_vty_command_description() OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE; - struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; diff --git a/include/osmocom/core/logging_internal.h b/include/osmocom/core/logging_internal.h new file mode 100644 index 00000000..55b1bbd8 --- /dev/null +++ b/include/osmocom/core/logging_internal.h @@ -0,0 +1,14 @@ +#pragma once + +/*! \defgroup logging_internal Osmocom logging internals + * @{ + * \file logging_internal.h */ + +#include <osmocom/core/utils.h> + +extern void *tall_log_ctx; +extern const struct log_info *osmo_log_info; + +void assert_loginfo(const char *src); + +/*! @} */ |