Make the __FILE__ and __LINE__ part of the log message.
[apple-ir-control.git] / apple-ir-control.cc
index 3ac6ba73ec36e203cd86f3df0efef6ec11e2f667..5a56489d56eace4d323873284ba145cd141d0523 100644 (file)
@@ -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: