Change in osmo-pcu[master]: gprs_debug: Use named initializers and explicit array indicies

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Mar 21 21:37:14 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13384


Change subject: gprs_debug: Use named initializers and explicit array indicies
......................................................................

gprs_debug: Use named initializers and explicit array indicies

This is a much safe way, it allows for modifications of the debug
subsystem enum member values without breakage.  Also, the syntax
introduced here is what we do in all other Osmocom CNI projects.

Change-Id: I2be88586ca44b0b8361f96cf3c034c8459244c2c
---
M src/gprs_debug.cpp
1 file changed, 99 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/84/13384/1

diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp
index f1ae6ad..91933a2 100644
--- a/src/gprs_debug.cpp
+++ b/src/gprs_debug.cpp
@@ -1,6 +1,7 @@
 /* gprs_debug.cpp
  *
  * Copyright (C) 2012 Ivan Klyuchnikov
+ * Copyright (C) 2019 Harald Welte <laforge at gnumonks.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -24,20 +25,104 @@
 /* default categories */
 
 static const struct log_info_cat default_categories[] = {
- 	{"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0},
- 	{"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_INFO, 1},
-	{"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_NOTICE, 1},
-	{"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_NOTICE, 1},
-	{"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_NOTICE, 1},
-	{"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_NOTICE, 1},
-	{"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_NOTICE, 1},
-	{"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1},
-	{"DTBF","\033[1;34m", "Temporary Block Flow (TBF)", LOGL_INFO , 1},
-	{"DTBFDL","\033[1;34m", "Temporary Block Flow (TBF) Downlink", LOGL_INFO , 1},
-	{"DTBFUL","\033[1;34m", "Temporary Block Flow (TBF) Uplink", LOGL_INFO , 1},
-	{"DNS","\033[1;34m", "GPRS Network Service Protocol (NS)", LOGL_INFO , 1},
-	{"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1},
-	{"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1},
+	[DCSN1] = {
+		.name = "DCSN1",
+		.color = "\033[1;31m",
+		.description = "Concrete Syntax Notation One (CSN1)",
+		.loglevel = LOGL_INFO,
+		.enabled = 0,
+	},
+	[DL1IF] = {
+		.name = "DL1IF",
+		.color = "\033[1;32m",
+		.description = "GPRS PCU L1 interface (L1IF)",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DRLCMAC] = {
+		.name = "DRLCMAC",
+		.color = "\033[0;33m",
+		.description = "GPRS RLC/MAC layer (RLCMAC)",
+		.loglevel = LOGL_NOTICE,
+		.enabled = 1,
+	},
+	[DRLCMACDATA] = {
+		.name = "DRLCMACDATA",
+		.color = "\033[0;33m",
+		.description = "GPRS RLC/MAC layer Data (RLCMAC)",
+		.loglevel = LOGL_NOTICE,
+		.enabled = 1,
+	},
+	[DRLCMACDL] = {
+		.name = "DRLCMACDL",
+		.color = "\033[1;33m",
+		.description = "GPRS RLC/MAC layer Downlink (RLCMAC)",
+		.loglevel = LOGL_NOTICE,
+		.enabled = 1,
+	},
+	[DRLCMACUL] = {
+		.name = "DRLCMACUL",
+		.color = "\033[1;36m",
+		.description = "GPRS RLC/MAC layer Uplink (RLCMAC)",
+		.loglevel = LOGL_NOTICE,
+		.enabled = 1,
+	},
+	[DRLCMACSCHED] = {
+		.name = "DRLCMACSCHED",
+		.color = "\033[0;36m",
+		.description = "GPRS RLC/MAC layer Scheduling (RLCMAC)",
+		.loglevel = LOGL_NOTICE,
+		.enabled = 1,
+	},
+	[DRLCMACMEAS] = {
+		.name = "DRLCMACMEAS",
+		.color = "\033[1;31m",
+		.description = "GPRS RLC/MAC layer Measurements (RLCMAC)",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DTBF] = {
+		.name = "DTBF",
+		.color = "\033[1;34m",
+		.description = "Temporary Block Flow (TBF)",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DTBFDL] = {
+		.name = "DTBFDL",
+		.color = "\033[1;34m",
+		.description = "Temporary Block Flow (TBF) Downlink",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DTBFUL] = {
+		.name = "DTBFUL",
+		.color = "\033[1;34m",
+		.description = "Temporary Block Flow (TBF) Uplink",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DNS] = {
+		.name = "DNS",
+		.color = "\033[1;34m",
+		.description = "GPRS Network Service Protocol (NS)",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DBSSGP] = {
+		.name = "DBSSGP",
+		.color = "\033[1;34m",
+		.description = "GPRS BSS Gateway Protocol (BSSGP)",
+		.loglevel = LOGL_INFO,
+		.enabled = 1,
+	},
+	[DPCU] = {
+		.name = "DPCU",
+		.color = "\033[1;35m",
+		.description = "GPRS Packet Control Unit (PCU)",
+		.loglevel = LOGL_NOTICE,
+		.enabled = 1,
+	},
 };
 
 static int filter_fn(const struct log_context *ctx,

-- 
To view, visit https://gerrit.osmocom.org/13384
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2be88586ca44b0b8361f96cf3c034c8459244c2c
Gerrit-Change-Number: 13384
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190321/c6f6a325/attachment.htm>


More information about the gerrit-log mailing list