mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
309d0e5483
commit
bb62cbc099
|
@ -64,6 +64,7 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
|
||||||
const char *subsys_name = log_category_name(subsys);
|
const char *subsys_name = log_category_name(subsys);
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int rc;
|
int rc;
|
||||||
|
const char *file_basename;
|
||||||
|
|
||||||
/* get timestamp ASAP */
|
/* get timestamp ASAP */
|
||||||
osmo_gettimeofday(&tv, NULL);
|
osmo_gettimeofday(&tv, NULL);
|
||||||
|
@ -86,6 +87,10 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
|
||||||
osmo_strlcpy(golh->subsys, subsys_name+1, sizeof(golh->subsys));
|
osmo_strlcpy(golh->subsys, subsys_name+1, sizeof(golh->subsys));
|
||||||
else
|
else
|
||||||
golh->subsys[0] = '\0';
|
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));
|
osmo_strlcpy(golh->src_file.name, file, sizeof(golh->src_file.name));
|
||||||
golh->src_file.line_nr = osmo_htonl(line);
|
golh->src_file.line_nr = osmo_htonl(line);
|
||||||
golh->level = level;
|
golh->level = level;
|
||||||
|
|
Loading…
Reference in New Issue