mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 22:00:05 +00:00 
			
		
		
		
	Logging: Fix fmt errors after rebasing with master
fmt was updated during the clang-format update, which breaks the previous implementation of FmtLogMessage Changes were: * Move definition of FmtLogMessage into log.h to use variadic templates as FMT_VARIADIC was removed To supplement the change above: * Move Entry and CreateEntry into log.h * Add LogEntry in backend.cpp
This commit is contained in:
		
							parent
							
								
									ab4ba71f3e
								
							
						
					
					
						commit
						eee388588e
					
				
					 3 changed files with 37 additions and 33 deletions
				
			
		|  | @ -265,15 +265,11 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned | ||||||
|     Impl::Instance().PushEntry(std::move(entry)); |     Impl::Instance().PushEntry(std::move(entry)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, | void LogEntry(Entry& entry) { | ||||||
|                    const char* function, const char* format, fmt::ArgList args) { |  | ||||||
|     auto filter = Impl::Instance().GetGlobalFilter(); |     auto filter = Impl::Instance().GetGlobalFilter(); | ||||||
|     if (!filter.CheckMessage(log_class, log_level)) |     if (!filter.CheckMessage(entry.log_class, entry.log_level)) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     Entry entry = |  | ||||||
|         CreateEntry(log_class, log_level, filename, line_num, function, fmt::format(format, args)); |  | ||||||
| 
 |  | ||||||
|     Impl::Instance().PushEntry(std::move(entry)); |     Impl::Instance().PushEntry(std::move(entry)); | ||||||
| } | } | ||||||
| } // namespace Log
 | } // namespace Log
 | ||||||
|  |  | ||||||
|  | @ -18,26 +18,6 @@ namespace Log { | ||||||
| 
 | 
 | ||||||
| class Filter; | class Filter; | ||||||
| 
 | 
 | ||||||
| /**
 |  | ||||||
|  * A log entry. Log entries are store in a structured format to permit more varied output |  | ||||||
|  * formatting on different frontends, as well as facilitating filtering and aggregation. |  | ||||||
|  */ |  | ||||||
| struct Entry { |  | ||||||
|     std::chrono::microseconds timestamp; |  | ||||||
|     Class log_class; |  | ||||||
|     Level log_level; |  | ||||||
|     std::string filename; |  | ||||||
|     unsigned int line_num; |  | ||||||
|     std::string function; |  | ||||||
|     std::string message; |  | ||||||
| 
 |  | ||||||
|     Entry() = default; |  | ||||||
|     Entry(Entry&& o) = default; |  | ||||||
| 
 |  | ||||||
|     Entry& operator=(Entry&& o) = default; |  | ||||||
|     Entry& operator=(const Entry& o) = default; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|  * Interface for logging backends. As loggers can be created and removed at runtime, this can be |  * Interface for logging backends. As loggers can be created and removed at runtime, this can be | ||||||
|  * used by a frontend for adding a custom logging backend as needed |  * used by a frontend for adding a custom logging backend as needed | ||||||
|  | @ -112,10 +92,6 @@ const char* GetLogClassName(Class log_class); | ||||||
|  */ |  */ | ||||||
| const char* GetLevelName(Level log_level); | const char* GetLevelName(Level log_level); | ||||||
| 
 | 
 | ||||||
| /// Creates a log entry by formatting the given source location, and message.
 |  | ||||||
| Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, |  | ||||||
|                   const char* function, std::string message); |  | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|  * The global filter will prevent any messages from even being processed if they are filtered. Each |  * The global filter will prevent any messages from even being processed if they are filtered. Each | ||||||
|  * backend can have a filter, but if the level is lower than the global filter, the backend will |  * backend can have a filter, but if the level is lower than the global filter, the backend will | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <chrono> | ||||||
| #include <fmt/format.h> | #include <fmt/format.h> | ||||||
| #include "common/common_types.h" | #include "common/common_types.h" | ||||||
| 
 | 
 | ||||||
|  | @ -98,6 +99,33 @@ enum class Class : ClassType { | ||||||
|     Count              ///< Total number of logging classes
 |     Count              ///< Total number of logging classes
 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | /**
 | ||||||
|  |  * A log entry. Log entries are store in a structured format to permit more varied output | ||||||
|  |  * formatting on different frontends, as well as facilitating filtering and aggregation. | ||||||
|  |  */ | ||||||
|  | struct Entry { | ||||||
|  |     std::chrono::microseconds timestamp; | ||||||
|  |     Class log_class; | ||||||
|  |     Level log_level; | ||||||
|  |     std::string filename; | ||||||
|  |     unsigned int line_num; | ||||||
|  |     std::string function; | ||||||
|  |     std::string message; | ||||||
|  | 
 | ||||||
|  |     Entry() = default; | ||||||
|  |     Entry(Entry&& o) = default; | ||||||
|  | 
 | ||||||
|  |     Entry& operator=(Entry&& o) = default; | ||||||
|  |     Entry& operator=(const Entry& o) = default; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | /// Creates a log entry by formatting the given source location, and message.
 | ||||||
|  | Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, | ||||||
|  |                   const char* function, std::string message); | ||||||
|  | 
 | ||||||
|  | // Logs an Entry
 | ||||||
|  | void LogEntry(Entry& entry); | ||||||
|  | 
 | ||||||
| /// Logs a message to the global logger.
 | /// Logs a message to the global logger.
 | ||||||
| void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, | void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, | ||||||
|                 const char* function, |                 const char* function, | ||||||
|  | @ -112,10 +140,14 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned | ||||||
|     ; |     ; | ||||||
| 
 | 
 | ||||||
| /// Logs a message to the global logger, this time with 100% moar fmtlib
 | /// Logs a message to the global logger, this time with 100% moar fmtlib
 | ||||||
|  | template <typename... Args> | ||||||
| void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, | void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, | ||||||
|                    const char* function, const char* format, fmt::ArgList); |                    const char* function, const char* format, const Args & ... args) { | ||||||
|  |     Entry entry = | ||||||
|  |         CreateEntry(log_class, log_level, filename, line_num, function, fmt::format(format, args...)); | ||||||
| 
 | 
 | ||||||
| FMT_VARIADIC(void, FmtLogMessage, Class, Level, const char*, unsigned int, const char*, const char*) |     LogEntry(entry); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| } // namespace Log
 | } // namespace Log
 | ||||||
| 
 | 
 | ||||||
|  | @ -163,4 +195,4 @@ FMT_VARIADIC(void, FmtLogMessage, Class, Level, const char*, unsigned int, const | ||||||
|                          __func__, fmt, ##__VA_ARGS__) |                          __func__, fmt, ##__VA_ARGS__) | ||||||
| #define NGLOG_CRITICAL(log_class, fmt, ...)                                                        \ | #define NGLOG_CRITICAL(log_class, fmt, ...)                                                        \ | ||||||
|     ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, __FILE__, __LINE__,      \ |     ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, __FILE__, __LINE__,      \ | ||||||
|                          __func__, fmt, ##__VA_ARGS__) | __func__, fmt, ##__VA_ARGS__) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue