[PATCH] osmo-hlr[master]: cosmetic: don't log about missing SQLite log cb

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.org
Tue Oct 10 14:50:10 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4175

to look at the new patch set (#3).

cosmetic: don't log about missing SQLite log cb

SQLite3 seems to be commonly compiled without log callback support. It is then
misleading to see a seeming error message about this on each osmo-hlr startup.

Avoid the impression that we would miss out on important logging: query
sqlit3_compileoption_get() whether SQLITE_CONFIG_SQLLOG is enabled. Try to
register the callback only if present, if not, say so on DEBUG log.

See https://sqlite.org/compile.html "SQLITE_ENABLE_SQLLOG"

Change-Id: I78d75dc351eb587b0a022f82f147e9a31c0324c5
---
M src/db.c
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/75/4175/3

diff --git a/src/db.c b/src/db.c
index 2c10ba0..4aadeb7 100644
--- a/src/db.c
+++ b/src/db.c
@@ -121,6 +121,7 @@
 	struct db_context *dbc = talloc_zero(ctx, struct db_context);
 	unsigned int i;
 	int rc;
+	bool has_sqlite_config_sqllog = false;
 
 	LOGP(DDB, LOGL_NOTICE, "using database: %s\n", fname);
 	LOGP(DDB, LOGL_INFO, "Compiled against SQLite3 lib version %s\n", SQLITE_VERSION);
@@ -133,15 +134,21 @@
 		if (!o)
 			break;
 		LOGP(DDB, LOGL_DEBUG, "SQlite3 compiled with '%s'\n", o);
+		if (!strcmp(o, "ENABLE_SQLLOG"))
+			has_sqlite_config_sqllog = true;
 	}
 
 	rc = sqlite3_config(SQLITE_CONFIG_LOG, sql3_error_log_cb, NULL);
 	if (rc != SQLITE_OK)
 		LOGP(DDB, LOGL_NOTICE, "Unable to set SQlite3 error log callback\n");
 
-	rc = sqlite3_config(SQLITE_CONFIG_SQLLOG, sql3_sql_log_cb, NULL);
-	if (rc != SQLITE_OK)
-		LOGP(DDB, LOGL_NOTICE, "Unable to set SQlite3 SQL statement log callback\n");
+	if (has_sqlite_config_sqllog) {
+		rc = sqlite3_config(SQLITE_CONFIG_SQLLOG, sql3_sql_log_cb, NULL);
+		if (rc != SQLITE_OK)
+			LOGP(DDB, LOGL_NOTICE, "Unable to set SQlite3 SQL log callback\n");
+	} else
+			LOGP(DDB, LOGL_DEBUG, "Not setting SQL log callback:"
+			     " SQLite3 compiled without support for it\n");
 
 	rc = sqlite3_open(dbc->fname, &dbc->db);
 	if (rc != SQLITE_OK) {

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I78d75dc351eb587b0a022f82f147e9a31c0324c5
Gerrit-PatchSet: 3
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list