From: Robert Sesek Date: Sat, 19 Mar 2016 17:56:07 +0000 (-0400) Subject: Make the __FILE__ and __LINE__ part of the log message. X-Git-Url: https://src.bluestatic.org/?a=commitdiff_plain;h=HEAD;p=apple-ir-control.git Make the __FILE__ and __LINE__ part of the log message. --- 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: