From 9baedbcc2a07b3bccc6d8b8d170498111b990adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Aug 2015 17:48:34 +0200 Subject: [PATCH] Shorter file path in ILOG/ELOG/WLOG etc on unix-likes --- base/logging.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/base/logging.h b/base/logging.h index 72837a4c6f..4bdba4aaa4 100644 --- a/base/logging.h +++ b/base/logging.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "base/arch.h" #include "base/backtrace.h" #include "base/compat.h" @@ -112,15 +114,20 @@ void OutputDebugStringUTF8(const char *p); #include +inline const char *removePath(const char *str) { + const char *slash = strrchr(str, '/'); + return slash ? (slash + 1) : str; +} + #ifdef _DEBUG -#define DLOG(...) {printf("D: %s:%i: ", __FILE__, __LINE__); printf("D: " __VA_ARGS__); printf("\n");} +#define DLOG(...) {printf("D: %s:%i: ", removePath(__FILE__), __LINE__); printf("D: " __VA_ARGS__); printf("\n");} #else #define DLOG(...) #endif -#define ILOG(...) {printf("I: %s:%i: ", __FILE__, __LINE__); printf("I: " __VA_ARGS__); printf("\n");} -#define WLOG(...) {printf("W: %s:%i: ", __FILE__, __LINE__); printf("W: " __VA_ARGS__); printf("\n");} -#define ELOG(...) {printf("E: %s:%i: ", __FILE__, __LINE__); printf("E: " __VA_ARGS__); printf("\n");} -#define FLOG(...) {printf("F: %s:%i: ", __FILE__, __LINE__); printf("F: " __VA_ARGS__); printf("\n"); Crash();} +#define ILOG(...) {printf("I: %s:%i: ", removePath(__FILE__), __LINE__); printf("I: " __VA_ARGS__); printf("\n");} +#define WLOG(...) {printf("W: %s:%i: ", removePath(__FILE__), __LINE__); printf("W: " __VA_ARGS__); printf("\n");} +#define ELOG(...) {printf("E: %s:%i: ", removePath(__FILE__), __LINE__); printf("E: " __VA_ARGS__); printf("\n");} +#define FLOG(...) {printf("F: %s:%i: ", removePath(__FILE__), __LINE__); printf("F: " __VA_ARGS__); printf("\n"); Crash();} #endif #endif