From 052f28853bc8e05a8987d217e04d5c34b3d32ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 1 Jul 2015 11:50:23 +0200 Subject: [PATCH] Cosmetics in debug in ssl_{client,server}2.c Print only the basename from the file, and print level too. --- programs/ssl/ssl_client2.c | 9 +++++++-- programs/ssl/ssl_server2.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 773bca6db..98f8528ae 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -315,9 +315,14 @@ static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) { - ((void) level); + const char *p, *basename; - mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + /* Extract basename from file */ + for( p = basename = file; *p != '\0'; p++ ) + if( *p == '/' || *p == '\\' ) + basename = p + 1; + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str ); fflush( (FILE *) ctx ); } diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index a08aa9b29..fb5c42fd9 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -394,9 +394,14 @@ static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) { - ((void) level); + const char *p, *basename; - mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); + /* Extract basename from file */ + for( p = basename = file; *p != '\0'; p++ ) + if( *p == '/' || *p == '\\' ) + basename = p + 1; + + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str ); fflush( (FILE *) ctx ); }