[PATCH] libosmocore[master]: logging-gsmtap: send only basename of source file

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
Fri Jan 12 04:44:40 UTC 2018


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

logging-gsmtap: send only basename of source file

GSMTAP doesn't have a lot of space for the source file name. It is better to
send only the basename of the file, because only the first bit of a long path
may not convey the source file at all, needing guess work from the line number.

Before:  "Source File Name: ../../../../src/libosmocore/src"
After:   "Source File Name: telnet_interface.c"

Change-Id: Ie8fc9e782bcf8fa6e2e957d02e7d73c3a7c2bca8
---
M src/logging_gsmtap.c
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/68/5768/1

diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index ec6757c..82535ad 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -64,6 +64,7 @@
 	const char *subsys_name = log_category_name(subsys);
 	struct timeval tv;
 	int rc;
+	const char *file_basename;
 
 	/* get timestamp ASAP */
 	osmo_gettimeofday(&tv, NULL);
@@ -86,6 +87,10 @@
 		osmo_strlcpy(golh->subsys, subsys_name+1, sizeof(golh->subsys));
 	else
 		golh->subsys[0] = '\0';
+
+	/* strip all leading path elements from file, if any. */
+	file_basename = strrchr(file, '/');
+	file = (file_basename && file_basename[1])? file_basename + 1 : file;
 	osmo_strlcpy(golh->src_file.name, file, sizeof(golh->src_file.name));
 	golh->src_file.line_nr = osmo_htonl(line);
 	golh->level = level;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8fc9e782bcf8fa6e2e957d02e7d73c3a7c2bca8
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