From d4ae0cd3d6687e909814ffc6c17825defef91591 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 1 Feb 2019 11:00:43 +0000 Subject: [PATCH] logger: format file name to remove leading directories. No need for full path as this breaks column formatting. Signed-off-by: Liam Girdwood --- tools/logger/convert.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/logger/convert.c b/tools/logger/convert.c index 55e1cff21..a1ec85c53 100644 --- a/tools/logger/convert.c +++ b/tools/logger/convert.c @@ -101,6 +101,25 @@ static const char * get_component_name(uint32_t component_id) { } } +/* remove superfluous leading file path and shrink to last 20 chars */ +static char *format_file_name(char *file_name_raw) +{ + char *name; + int len; + + /* most/all string should have "src" */ + name = strstr(file_name_raw, "src"); + if (!name) + name = file_name_raw; + + /* keep the last 20 chars */ + len = strlen(name); + if (len > 20) + name += (len - 20); + + return name; +} + static void print_entry_params(FILE *out_fd, const struct log_entry_header *dma_log, const struct ldc_entry *entry, uint64_t last_timestamp, double clock, int use_colors) @@ -124,7 +143,7 @@ static void print_entry_params(FILE *out_fd, entry->header.has_ids ? ids : "", to_usecs(dma_log->timestamp, clock), dt, - entry->file_name, + format_file_name(entry->file_name), entry->header.line_idx); switch (entry->header.params_num) {