From 17bd6e99dc688155cf539ab20015f08f296a3a34 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 19 Mar 2016 13:56:07 -0400 Subject: [PATCH] Make the __FILE__ and __LINE__ part of the log message. --- apple-ir-control.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apple-ir-control.cc b/apple-ir-control.cc index 3ac6ba7..5a56489 100644 --- a/apple-ir-control.cc +++ b/apple-ir-control.cc @@ -22,12 +22,15 @@ const bool VERBOSE = false; const bool VERBOSE = true; #endif +#define LOCATION_LINE(x) #x +#define LOCATION(line) __FILE__ ":" LOCATION_LINE(line) + #define LOG(msg, ...) do { \ if (VERBOSE) { \ - printf(msg " [%s:%d]\n", ##__VA_ARGS__, __FILE__, __LINE__); \ + printf("[" LOCATION(__LINE__) "] " msg "\n", ##__VA_ARGS__); \ } \ } while(0) -#define ERROR(msg, ...) fprintf(stderr, msg " [%s:%d]\n", ##__VA_ARGS__, __FILE__, __LINE__) +#define ERROR(msg, ...) fprintf(stderr, "[" LOCATION(__LINE__) "] " msg "\n", ##__VA_ARGS__) class ScopedIOHIDManager { public: -- 2.43.5