fix compile issues
This commit is contained in:
		
							
								
								
									
										20
									
								
								logging.h
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								logging.h
									
									
									
									
									
								
							| @@ -19,7 +19,7 @@ | ||||
| #define LOGGING_COLOR true // enable color | ||||
| #define LOGGING_TIMESTAMP true // enable timestamp | ||||
| #define LOGGING_TIMESTAMP_FMT "%Y-%m-%dT%H:%M:%S%z" // timestamp format (local time) | ||||
| #define LOGGING_POSITION true // display position (only works on C++20 or newer) | ||||
| #define LOGGING_POSITION false // display position (only works on C++20 or newer) | ||||
|  | ||||
| // Color codes | ||||
| #define ANSI_RESET   "\033[0m" | ||||
| @@ -33,15 +33,9 @@ | ||||
| #define ANSI_WHITE   "\033[37m"      /* White */ | ||||
| #define ANSI_BOLD    "\033[1m"       /* Bold */ | ||||
|  | ||||
| template <typename T> | ||||
| void print(T t) { | ||||
|   std::cout << t << std::endl; | ||||
| } | ||||
|  | ||||
| template <typename T, typename... Args> | ||||
| void print(T t, Args... args) { | ||||
|   std::cout << t; | ||||
|   print(args...); | ||||
| template <typename... Args> | ||||
| void print(Args... args) { | ||||
|   (std::cout << ... << args) << "\n"; | ||||
| } | ||||
|  | ||||
| inline void printTimestamp() { | ||||
| @@ -55,13 +49,11 @@ inline void printTimestamp() { | ||||
| } | ||||
|  | ||||
| // if we're on C++20 or later, then use the source_location header and add source location to logs | ||||
| #if __cplusplus >= 202002L | ||||
| #if __cplusplus >= 202002L && LOGGING_POSITION | ||||
| #include <source_location> | ||||
|  | ||||
| inline void printPosition(std::source_location& location) { | ||||
|   #if LOGGING_POSITION | ||||
|   std::cout << location.file_name() << ":" << location.function_name << ":" << ANSI_CYAN << location.line() << ANSI_RESET <<  ": "; | ||||
|   #endif | ||||
|   std::cout << location.file_name() << ":" << location.function_name() << ":" << ANSI_CYAN << location.line() << ANSI_RESET <<  ": "; | ||||
| } | ||||
|  | ||||
| inline void printHeader(std::string name, std::string color, std::source_location& location) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user