From 3b558eebee54fa4bc9d1a7bb428d4bd33e1b817e Mon Sep 17 00:00:00 2001
From: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
Date: Thu, 22 Mar 2018 18:21:29 +0800
Subject: Logging: Create logging macros based on fmtlib

Add a new set of logging macros based on fmtlib
Similar but not exactly the same as https://github.com/citra-emu/citra/pull/3533

Citra currently uses a different version of fmt, which does not support FMT_VARIADIC so
make_args is used instead. On the other hand, yuzu uses fmt 4.1.0 which doesn't have make_args yet
so FMT_VARIADIC is used.
---
 src/common/logging/log.h | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

(limited to 'src/common/logging/log.h')

diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 3cf13fcb0f..31fa932fba 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -4,6 +4,8 @@
 
 #pragma once
 
+#include <chrono>
+#include <fmt/format.h>
 #include "common/common_types.h"
 
 namespace Log {
@@ -87,7 +89,7 @@ enum class Class : ClassType {
 };
 
 /// Logs a message to the global logger.
-void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
+void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
                 const char* function,
 #ifdef _MSC_VER
                 _Printf_format_string_
@@ -99,6 +101,10 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
 #endif
     ;
 
+void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
+                   const char* function, const char* format, const fmt::ArgList& args);
+FMT_VARIADIC(void, FmtLogMessage, Class, Level, const char*, unsigned int, const char*, const char*)
+
 } // namespace Log
 
 #define LOG_GENERIC(log_class, log_level, ...)                                                     \
@@ -121,3 +127,28 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
     LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Error, __VA_ARGS__)
 #define LOG_CRITICAL(log_class, ...)                                                               \
     LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Critical, __VA_ARGS__)
+
+// Define the fmt lib macros
+#ifdef _DEBUG
+#define NGLOG_TRACE(log_class, ...)                                                                \
+    ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, __FILE__, __LINE__,         \
+                         __func__, __VA_ARGS__)
+#else
+#define NGLOG_TRACE(log_class, fmt, ...) (void(0))
+#endif
+
+#define NGLOG_DEBUG(log_class, ...)                                                                \
+    ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, __FILE__, __LINE__,         \
+                         __func__, __VA_ARGS__)
+#define NGLOG_INFO(log_class, ...)                                                                 \
+    ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, __FILE__, __LINE__,          \
+                         __func__, __VA_ARGS__)
+#define NGLOG_WARNING(log_class, ...)                                                              \
+    ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, __FILE__, __LINE__,       \
+                         __func__, __VA_ARGS__)
+#define NGLOG_ERROR(log_class, ...)                                                                \
+    ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, __FILE__, __LINE__,         \
+                         __func__, __VA_ARGS__)
+#define NGLOG_CRITICAL(log_class, ...)                                                             \
+    ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, __FILE__, __LINE__,      \
+                         __func__, __VA_ARGS__)
-- 
cgit v1.2.3-70-g09d2


From 8529d84f31f94502d97a43a723275049c2cb79d7 Mon Sep 17 00:00:00 2001
From: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
Date: Thu, 22 Mar 2018 21:53:51 +0800
Subject: Remove dependency chrono

Earlier chrono was included but after some code changed it was no longer needed

Forgot to remove it so I'm removing it now
---
 src/common/logging/log.h | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src/common/logging/log.h')

diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 31fa932fba..7f6d2ade89 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -4,7 +4,6 @@
 
 #pragma once
 
-#include <chrono>
 #include <fmt/format.h>
 #include "common/common_types.h"
 
-- 
cgit v1.2.3-70-g09d2