Change in libosmocore[master]: application.c: check default loglevels on startup

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

dexter gerrit-no-reply at lists.osmocom.org
Mon Jan 13 12:48:11 UTC 2020


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/16833 )


Change subject: application.c: check default loglevels on startup
......................................................................

application.c: check default loglevels on startup

Default log levels should not be set lower than LOGL_NOTICE. If a lower
loglevel is desired, this loglevel should be set via a configuration
file. Lets print a warning if a default loglevel lower than LOGL_NOTICE
is set to remind the programmer to set proper default loglevels.

Related: OS#2577
Change-Id: I2d7e345c14a188430a0e991bfd9fb0343d05ea92
---
M src/application.c
1 file changed, 17 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/33/16833/1

diff --git a/src/application.c b/src/application.c
index 7fd6280..a7ed01e 100644
--- a/src/application.c
+++ b/src/application.c
@@ -117,6 +117,21 @@
 	return osmo_init_logging2(NULL, log_info);
 }
 
+/* Check preset loglevels. This check prints a warning if the default loglevel
+ * is lower than LOGL_NOTICE, which should never be the default */
+static void check_loglevels(const struct log_info *log_info)
+{
+	unsigned int i;
+	for (i = 0; i < log_info->num_cat; i++) {
+		if (log_info->cat[i].loglevel < LOGL_NOTICE) {
+			printf
+			    ("FIXME: The default loglevel of %s is set to %s. Default log levels should not be lower than LOGL_NOTICE -- please fix!\n",
+			     log_info->cat[i].name,
+			     log_level_name(log_info->cat[i].loglevel));
+		}
+	}
+}
+
 int osmo_init_logging2(void *ctx, const struct log_info *log_info)
 {
 	static int logging_initialized = 0;
@@ -132,6 +147,8 @@
 
 	log_add_target(osmo_stderr_target);
 	log_set_all_filter(osmo_stderr_target, 1);
+	check_loglevels(log_info);
+
 	return 0;
 }
 

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2d7e345c14a188430a0e991bfd9fb0343d05ea92
Gerrit-Change-Number: 16833
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200113/11d33d33/attachment.htm>


More information about the gerrit-log mailing list