[PATCH] libosmocore[master]: logging.h: fixup: shorter names for LOGGING_FILTER_* and LOG...

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Feb 23 17:12:43 UTC 2017


Review at  https://gerrit.osmocom.org/1878

logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*

My recent logging patch was merged to master a bit too soon. Accomodate the
request for naming that matches the general "LOG" prefix instead of "LOGGING".

libosmocore will not be backwards-compatible with the few commits from
change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and
following commits are backwards compatible with those before that short window.

See also:
* openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991
* osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685

Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93
---
M include/osmocom/core/logging.h
M src/gb/common_vty.c
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gb/gprs_ns.c
M src/gb/gprs_ns_vty.c
M src/logging.c
M src/vty/logging_vty.c
8 files changed, 61 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/1878/1

diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index c4d8006..7b28b2c 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -126,32 +126,34 @@
 
 /*! \brief Indexes to indicate the object currently acted upon.
  * Array indexes for the global \a log_context array. */
-enum logging_ctx_items {
-	LOGGING_CTX_GB_NSVC,
-	LOGGING_CTX_GB_BVC,
-	LOGGING_CTX_BSC_SUBSCR,
-	LOGGING_CTX_VLR_SUBSCR,
-	_LOGGING_CTX_COUNT
+enum log_ctx_index {
+	LOG_CTX_GB_NSVC,
+	LOG_CTX_GB_BVC,
+	LOG_CTX_BSC_SUBSCR,
+	LOG_CTX_VLR_SUBSCR,
+	_LOG_CTX_COUNT
 };
 
 /*! \brief Indexes to indicate objects that should be logged.
  * Array indexes to log_target->filter_data and bit indexes for
  * log_target->filter_map. */
-enum logging_filters {
-	LOGGING_FILTER_ALL,
-	LOGGING_FILTER_GB_NSVC,
-	LOGGING_FILTER_GB_BVC,
-	LOGGING_FILTER_BSC_SUBSCR,
-	LOGGING_FILTER_VLR_SUBSCR,
-	_LOGGING_FILTER_COUNT
+enum log_filter_index {
+	LOG_FLT_ALL,
+	LOG_FLT_GB_NSVC,
+	LOG_FLT_GB_BVC,
+	LOG_FLT_BSC_SUBSCR,
+	LOG_FLT_VLR_SUBSCR,
+	_LOG_FLT_COUNT
 };
 
 /*! \brief Compatibility with older libosmocore versions */
-#define LOG_FILTER_ALL (1<<LOGGING_FILTER_ALL)
+#define LOG_FILTER_ALL (1<<LOG_FLT_ALL)
 /*! \brief Compatibility with older libosmocore versions */
-#define GPRS_CTX_NSVC LOGGING_CTX_GB_NSVC
+#define GPRS_CTX_NSVC LOG_CTX_GB_NSVC
 /*! \brief Compatibility with older libosmocore versions */
-#define GPRS_CTX_BVC LOGGING_CTX_GB_BVC
+#define GPRS_CTX_BVC LOG_CTX_GB_BVC
+/*! \brief Indexes to indicate the object currently acted upon.
+ * Array indexes for the global \a log_context array. */
 
 struct log_target;
 
diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c
index 609ab3d..5848a11 100644
--- a/src/gb/common_vty.c
+++ b/src/gb/common_vty.c
@@ -70,17 +70,17 @@
 int gprs_log_filter_fn(const struct log_context *ctx,
 			struct log_target *tar)
 {
-	const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC];
-	const struct gprs_bvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC];
+	const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC];
+	const struct gprs_bvc *bvc = ctx->ctx[LOG_CTX_GB_BVC];
 
 	/* Filter on the NS Virtual Connection */
-	if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0
-	    && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC]))
+	if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
+	    && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
 		return 1;
 
 	/* Filter on the NS Virtual Connection */
-	if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0
-	    && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC]))
+	if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
+	    && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
 		return 1;
 
 	return 0;
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index a402378..dba4d5c 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -1049,7 +1049,7 @@
 	bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg));
 
 	if (bctx) {
-		log_set_context(LOGGING_CTX_GB_BVC, bctx);
+		log_set_context(LOG_CTX_GB_BVC, bctx);
 		rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]);
 		rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN],
 			     msgb_bssgp_len(msg));
diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c
index d8fc840..f3f354c 100644
--- a/src/gb/gprs_bssgp_vty.c
+++ b/src/gb/gprs_bssgp_vty.c
@@ -47,11 +47,11 @@
 				struct bssgp_bvc_ctx *bctx)
 {
 	if (bctx) {
-		target->filter_map |= (1 << LOGGING_FILTER_GB_BVC);
-		target->filter_data[LOGGING_FILTER_GB_BVC] = bctx;
-	} else if (target->filter_data[LOGGING_FILTER_GB_BVC]) {
-		target->filter_map = ~(1 << LOGGING_FILTER_GB_BVC);
-		target->filter_data[LOGGING_FILTER_GB_BVC] = NULL;
+		target->filter_map |= (1 << LOG_FLT_GB_BVC);
+		target->filter_data[LOG_FLT_GB_BVC] = bctx;
+	} else if (target->filter_data[LOG_FLT_GB_BVC]) {
+		target->filter_map = ~(1 << LOG_FLT_GB_BVC);
+		target->filter_data[LOG_FLT_GB_BVC] = NULL;
 	}
 }
 
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 28f5ff3..76e70ff 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -325,7 +325,7 @@
 {
 	int ret;
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
 	/* Increment number of Uplink bytes */
 	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]);
@@ -360,7 +360,7 @@
 	struct msgb *msg = gprs_ns_msgb_alloc();
 	struct gprs_ns_hdr *nsh;
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
 	if (!msg)
 		return -ENOMEM;
@@ -384,7 +384,7 @@
 	uint16_t nsvci = htons(nsvc->nsvci);
 	uint16_t nsei = htons(nsvc->nsei);
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
 	if (!msg)
 		return -ENOMEM;
@@ -416,7 +416,7 @@
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci = htons(nsvc->nsvci);
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
 	bvci = htons(bvci);
 
@@ -469,7 +469,7 @@
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci = htons(nsvc->nsvci);
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
 	if (!msg)
 		return -ENOMEM;
@@ -497,7 +497,7 @@
  */
 int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc)
 {
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 	LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
@@ -510,7 +510,7 @@
  */
 int gprs_ns_tx_alive(struct gprs_nsvc *nsvc)
 {
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 	LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
@@ -523,7 +523,7 @@
  */
 int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc)
 {
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 	LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
@@ -548,7 +548,7 @@
 	enum ns_timeout tout = timer_mode_tout[mode];
 	unsigned int seconds = nsvc->nsi->timeout[tout];
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 	DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n",
 		nsvc->nsei, get_value_string(timer_mode_strs, mode),
 		seconds);
@@ -576,7 +576,7 @@
 	enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode];
 	unsigned int seconds = nsvc->nsi->timeout[tout];
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 	DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n",
 		nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode),
 		seconds);
@@ -638,7 +638,7 @@
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci, nsei;
 
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 	if (!msg)
 		return -ENOMEM;
 
@@ -692,7 +692,7 @@
 		msgb_free(msg);
 		return rc;
 	}
-	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, nsvc);
 
 	msg->l2h = msgb_push(msg, sizeof(*nsh) + 3);
 	nsh = (struct gprs_ns_hdr *) msg->l2h;
@@ -1099,7 +1099,7 @@
 		struct gprs_nsvc *fallback_nsvc;
 
 		fallback_nsvc = nsi->unknown_nsvc;
-		log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc);
+		log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc);
 		fallback_nsvc->ip.bts_addr = *saddr;
 		fallback_nsvc->ll = ll;
 
@@ -1215,7 +1215,7 @@
 	/* Only the RESET procedure creates a new NSVC */
 	if (nsh->pdu_type != NS_PDUT_RESET) {
 		/* Since we have no NSVC, we have to use a fake */
-		log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc);
+		log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc);
 		LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x "
 		     "from %s for non-existing NS-VC\n",
 		     nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc));
@@ -1256,7 +1256,7 @@
 	if (!existing_nsvc) {
 		*new_nsvc = gprs_nsvc_create(nsi, 0xffff);
 		(*new_nsvc)->nsvci_is_valid = 0;
-		log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc);
+		log_set_context(LOG_CTX_GB_NSVC, *new_nsvc);
 		gprs_ns_ll_copy(*new_nsvc, fallback_nsvc);
 		LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n",
 		     gprs_ns_ll_str(fallback_nsvc));
@@ -1299,7 +1299,7 @@
 
 	msgb_nsei(msg) = (*nsvc)->nsei;
 
-	log_set_context(LOGGING_CTX_GB_NSVC, *nsvc);
+	log_set_context(LOG_CTX_GB_NSVC, *nsvc);
 
 	/* Increment number of Incoming bytes */
 	rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]);
diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c
index 2026c7a..6de74dd 100644
--- a/src/gb/gprs_ns_vty.c
+++ b/src/gb/gprs_ns_vty.c
@@ -61,11 +61,11 @@
 				struct gprs_nsvc *nsvc)
 {
 	if (nsvc) {
-		target->filter_map |= (1 << LOGGING_FILTER_GB_NSVC);
-		target->filter_data[LOGGING_FILTER_GB_NSVC] = nsvc;
-	} else if (target->filter_data[LOGGING_FILTER_GB_NSVC]) {
-		target->filter_map = ~(1 << LOGGING_FILTER_GB_NSVC);
-		target->filter_data[LOGGING_FILTER_GB_NSVC] = NULL;
+		target->filter_map |= (1 << LOG_FLT_GB_NSVC);
+		target->filter_data[LOG_FLT_GB_NSVC] = nsvc;
+	} else if (target->filter_data[LOG_FLT_GB_NSVC]) {
+		target->filter_map = ~(1 << LOG_FLT_GB_NSVC);
+		target->filter_data[LOG_FLT_GB_NSVC] = NULL;
 	}
 }
 
diff --git a/src/logging.c b/src/logging.c
index b09d684..6a1e929 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -48,11 +48,11 @@
 
 #include <osmocom/vty/logging.h>	/* for LOGGING_STR. */
 
-osmo_static_assert(_LOGGING_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx),
+osmo_static_assert(_LOG_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx),
 		   enum_logging_ctx_items_fit_in_struct_log_context);
-osmo_static_assert(_LOGGING_FILTER_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data),
+osmo_static_assert(_LOG_FLT_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data),
 		   enum_logging_filters_fit_in_log_target_filter_data);
-osmo_static_assert(_LOGGING_FILTER_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map),
+osmo_static_assert(_LOG_FLT_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map),
 		   enum_logging_filters_fit_in_log_target_filter_map);
 
 struct log_info *osmo_log_info;
@@ -381,7 +381,7 @@
 	/* Apply filters here... if that becomes messy we will
 	 * need to put filters in a list and each filter will
 	 * say stop, continue, output */
-	if ((tar->filter_map & (1 << LOGGING_FILTER_ALL)) != 0)
+	if ((tar->filter_map & (1 << LOG_FLT_ALL)) != 0)
 		return 1;
 
 	if (osmo_log_info->filter_fn)
@@ -499,20 +499,20 @@
 	return 0;
 }
 
-/*! \brief Enable the \ref LOGGING_FILTER_ALL log filter
+/*! \brief Enable the \ref LOG_FLT_ALL log filter
  *  \param[in] target Log target to be affected
  *  \param[in] all enable (1) or disable (0) the ALL filter
  *
- * When the \ref LOGGING_FILTER_ALL filter is enabled, all log messages will be
+ * When the \ref LOG_FLT_ALL filter is enabled, all log messages will be
  * printed.  It acts as a wildcard.  Setting it to \a 1 means there is no
  * filtering.
  */
 void log_set_all_filter(struct log_target *target, int all)
 {
 	if (all)
-		target->filter_map |= (1 << LOGGING_FILTER_ALL);
+		target->filter_map |= (1 << LOG_FLT_ALL);
 	else
-		target->filter_map &= ~(1 << LOGGING_FILTER_ALL);
+		target->filter_map &= ~(1 << LOG_FLT_ALL);
 }
 
 /*! \brief Enable or disable the use of colored output
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 30ee455..aabcaa7 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -287,7 +287,7 @@
 	}
 
 	vty_out(vty, " Log Filter 'ALL': %s%s",
-		tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? "Enabled" : "Disabled",
+		tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled",
 		VTY_NEWLINE);
 
 	/* print application specific filters */
@@ -687,7 +687,7 @@
 	}
 
 	vty_out(vty, "  logging filter all %u%s",
-		tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? 1 : 0, VTY_NEWLINE);
+		tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE);
 	/* save filters outside of libosmocore, i.e. in app code */
 	if (osmo_log_info->save_fn)
 		osmo_log_info->save_fn(vty, osmo_log_info, tgt);

-- 
To view, visit https://gerrit.osmocom.org/1878
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list