[fuchsia][logging] Use new logging macro and pass file and line

Change-Id: I9d4c4e1df51be5ab404f29a63a7d03c1993e4c91
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/mesa/+/456558
Reviewed-by: Craig Stout <cstout@google.com>
diff --git a/src/intel/common/intel_log.c b/src/intel/common/intel_log.c
index 7a2cc7c..8c0d07d 100644
--- a/src/intel/common/intel_log.c
+++ b/src/intel/common/intel_log.c
@@ -34,64 +34,72 @@
 #include "intel_log.h"
 
 #ifdef ANDROID
-static inline android_LogPriority
-level_to_android(enum intel_log_level l)
+static inline android_LogPriority level_to_android(enum intel_log_level l)
 {
    switch (l) {
-   case INTEL_LOG_ERROR: return ANDROID_LOG_ERROR;
-   case INTEL_LOG_WARN: return ANDROID_LOG_WARN;
-   case INTEL_LOG_INFO: return ANDROID_LOG_INFO;
-   case INTEL_LOG_DEBUG: return ANDROID_LOG_DEBUG;
+   case INTEL_LOG_ERROR:
+      return ANDROID_LOG_ERROR;
+   case INTEL_LOG_WARN:
+      return ANDROID_LOG_WARN;
+   case INTEL_LOG_INFO:
+      return ANDROID_LOG_INFO;
+   case INTEL_LOG_DEBUG:
+      return ANDROID_LOG_DEBUG;
    }
 
    unreachable("bad intel_log_level");
 }
 #elif defined(__Fuchsia__)
-static inline fx_log_severity_t
-level_to_fuchsia(enum intel_log_level l)
+static inline fx_log_severity_t level_to_fuchsia(enum intel_log_level l)
 {
    switch (l) {
-   case INTEL_LOG_ERROR: return FX_LOG_ERROR;
-   case INTEL_LOG_WARN: return FX_LOG_WARNING;
-   case INTEL_LOG_INFO: return FX_LOG_INFO;
-   case INTEL_LOG_DEBUG: return FX_LOG_INFO;
+   case INTEL_LOG_ERROR:
+      return FX_LOG_ERROR;
+   case INTEL_LOG_WARN:
+      return FX_LOG_WARNING;
+   case INTEL_LOG_INFO:
+      return FX_LOG_INFO;
+   case INTEL_LOG_DEBUG:
+      return FX_LOG_INFO;
    }
 
    unreachable("bad intel_log_level");
 }
 #else
-static inline const char *
-level_to_str(enum intel_log_level l)
+static inline const char* level_to_str(enum intel_log_level l)
 {
    switch (l) {
-   case INTEL_LOG_ERROR: return "error";
-   case INTEL_LOG_WARN: return "warning";
-   case INTEL_LOG_INFO: return "info";
-   case INTEL_LOG_DEBUG: return "debug";
+   case INTEL_LOG_ERROR:
+      return "error";
+   case INTEL_LOG_WARN:
+      return "warning";
+   case INTEL_LOG_INFO:
+      return "info";
+   case INTEL_LOG_DEBUG:
+      return "debug";
    }
 
    unreachable("bad intel_log_level");
 }
 #endif
 
-void
-intel_log(enum intel_log_level level, const char *tag, const char *format, ...)
+void intel_log(enum intel_log_level level, const char* tag, const char* file, int line,
+               const char* format, ...)
 {
    va_list va;
 
    va_start(va, format);
-   intel_log_v(level, tag, format, va);
+   intel_log_v(level, tag, file, line, format, va);
    va_end(va);
 }
 
-void
-intel_log_v(enum intel_log_level level, const char *tag, const char *format,
-            va_list va)
+void intel_log_v(enum intel_log_level level, const char* tag, const char* file, int line,
+                 const char* format, va_list va)
 {
 #ifdef ANDROID
    __android_log_vprint(level_to_android(level), tag, format, va);
 #elif defined(__Fuchsia__)
-   _FX_LOGVF(level_to_fuchsia(level), tag, format, va);
+   _FX_LOGVF2(level_to_fuchsia(level), tag, file, line, format, va);
 #else
    flockfile(stderr);
    fprintf(stderr, "%s: %s: ", tag, level_to_str(level));
diff --git a/src/intel/common/intel_log.h b/src/intel/common/intel_log.h
index 0f28109..27ae9dd 100644
--- a/src/intel/common/intel_log.h
+++ b/src/intel/common/intel_log.h
@@ -43,36 +43,44 @@
    INTEL_LOG_DEBUG,
 };
 
-void PRINTFLIKE(3, 4)
-intel_log(enum intel_log_level, const char *tag, const char *format, ...);
+void PRINTFLIKE(5, 6) intel_log(enum intel_log_level, const char* tag, const char* file, int line,
+                                const char* format, ...);
 
-void
-intel_log_v(enum intel_log_level, const char *tag, const char *format,
-            va_list va);
+void intel_log_v(enum intel_log_level, const char* tag, const char* file, int line,
+                 const char* format, va_list va);
 
-#define intel_loge(fmt, ...) intel_log(INTEL_LOG_ERROR, (INTEL_LOG_TAG), (fmt), ##__VA_ARGS__)
-#define intel_logw(fmt, ...) intel_log(INTEL_LOG_WARN, (INTEL_LOG_TAG), (fmt), ##__VA_ARGS__)
-#define intel_logi(fmt, ...) intel_log(INTEL_LOG_INFO, (INTEL_LOG_TAG), (fmt), ##__VA_ARGS__)
+#define intel_loge(fmt, ...)                                                                       \
+   intel_log(INTEL_LOG_ERROR, (INTEL_LOG_TAG), __FILE__, __LINE__, (fmt), ##__VA_ARGS__)
+#define intel_logw(fmt, ...)                                                                       \
+   intel_log(INTEL_LOG_WARN, (INTEL_LOG_TAG), __FILE__, __LINE__, (fmt), ##__VA_ARGS__)
+#define intel_logi(fmt, ...)                                                                       \
+   intel_log(INTEL_LOG_INFO, (INTEL_LOG_TAG), __FILE__, __LINE__, (fmt), ##__VA_ARGS__)
 #ifdef DEBUG
-#define intel_logd(fmt, ...) intel_log(INTEL_LOG_DEBUG, (INTEL_LOG_TAG), (fmt), ##__VA_ARGS__)
+#define intel_logd(fmt, ...)                                                                       \
+   intel_log(INTEL_LOG_DEBUG, (INTEL_LOG_TAG), __FILE__, __LINE__, (fmt), ##__VA_ARGS__)
 #else
-#define intel_logd(fmt, ...) __intel_log_use_args((fmt), ##__VA_ARGS__)
+#define intel_logd(fmt, ...) __intel_log_use_args(__FILE__, __LINE__, (fmt), ##__VA_ARGS__)
 #endif
 
-#define intel_loge_v(fmt, va) intel_log_v(INTEL_LOG_ERROR, (INTEL_LOG_TAG), (fmt), (va))
-#define intel_logw_v(fmt, va) intel_log_v(INTEL_LOG_WARN, (INTEL_LOG_TAG), (fmt), (va))
-#define intel_logi_v(fmt, va) intel_log_v(INTEL_LOG_INFO, (INTEL_LOG_TAG), (fmt), (va))
+#define intel_loge_v(file, line, fmt, va)                                                          \
+   intel_log_v(INTEL_LOG_ERROR, (INTEL_LOG_TAG), (file), (line), (fmt), (va))
+#define intel_logw_v(file, line, fmt, va)                                                          \
+   intel_log_v(INTEL_LOG_WARN, (INTEL_LOG_TAG), (file), (line), (fmt), (va))
+#define intel_logi_v(file, line, fmt, va)                                                          \
+   intel_log_v(INTEL_LOG_INFO, (INTEL_LOG_TAG), (file), (line), (fmt), (va))
 #ifdef DEBUG
-#define intel_logd_v(fmt, va) intel_log_v(INTEL_LOG_DEBUG, (INTEL_LOG_TAG), (fmt), (va))
+#define intel_logd_v(file, line, fmt, va)                                                          \
+   intel_log_v(INTEL_LOG_DEBUG, (INTEL_LOG_TAG), (file), (line), (fmt), (va))
 #else
-#define intel_logd_v(fmt, va) __intel_log_use_args((fmt), (va))
+#define intel_logd_v(file, line, fmt, va) __intel_log_use_args((file), (line), (fmt), (va))
 #endif
 
-
 #ifndef DEBUG
 /* Suppres -Wunused */
-static inline void PRINTFLIKE(1, 2)
-__intel_log_use_args(const char *format, ...) { }
+static inline void PRINTFLIKE(3, 4)
+    __intel_log_use_args(const char* file, int line, const char* format, ...)
+{
+}
 #endif
 
 #ifdef __cplusplus
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 257d8b6..ea1caba 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -102,7 +102,7 @@
    va_start(args, fmt);
 
    if (unlikely(INTEL_DEBUG & DEBUG_PERF))
-      intel_logd_v(fmt, args);
+      intel_logd_v(__FILE__, __LINE__, fmt, args);
 
    va_end(args);
 }
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 065c395..b09f9bb 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -494,8 +494,8 @@
                      VkDebugReportObjectTypeEXT type, const char *file,
                      int line, const char *format, ...)
    anv_printflike(6, 7);
-void anv_loge(const char *format, ...) anv_printflike(1, 2);
-void anv_loge_v(const char *format, va_list va);
+void anv_loge(const char* file, int line, const char *format, ...) anv_printflike(3, 4);
+void anv_loge_v(const char* file, int line, const char *format, va_list va);
 
 /**
  * Print a FINISHME message, including its source location.
diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
index 58d2efc..4554c08 100644
--- a/src/intel/vulkan/anv_util.c
+++ b/src/intel/vulkan/anv_util.c
@@ -32,21 +32,21 @@
 #include "vk_enum_to_str.h"
 
 /** Log an error message.  */
-void anv_printflike(1, 2)
-anv_loge(const char *format, ...)
+void anv_printflike(3, 4)
+anv_loge(const char* file, int line, const char *format, ...)
 {
    va_list va;
 
    va_start(va, format);
-   anv_loge_v(format, va);
+   anv_loge_v(file, line, format, va);
    va_end(va);
 }
 
 /** \see anv_loge() */
 void
-anv_loge_v(const char *format, va_list va)
+anv_loge_v(const char* file, int line, const char *format, va_list va)
 {
-   intel_loge_v(format, va);
+   intel_loge_v(file, line, format, va);
 }
 
 void anv_printflike(6, 7)