mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Make log_file_info() use variadic templates.
This commit is contained in:
		
							parent
							
								
									2e939faa45
								
							
						
					
					
						commit
						aa3eb6f62a
					
				
					 2 changed files with 11 additions and 17 deletions
				
			
		|  | @ -203,13 +203,6 @@ static void logv_string(std::string_view format, std::string str) { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void logv(const char *format, va_list ap) | ||||
| { | ||||
| 	if (log_make_debug && !ys_debug(1)) | ||||
| 		return; | ||||
| 	logv_string(format, vstringf(format, ap)); | ||||
| } | ||||
| 
 | ||||
| void log_formatted_string(std::string_view format, std::string str) | ||||
| { | ||||
| 	if (log_make_debug && !ys_debug(1)) | ||||
|  | @ -322,15 +315,9 @@ void log_formatted_file_warning(std::string_view filename, int lineno, std::stri | |||
| 	log_formatted_warning(prefix, std::move(str)); | ||||
| } | ||||
| 
 | ||||
| void log_file_info(const std::string &filename, int lineno, | ||||
|                       const char *format, ...) | ||||
| void log_formatted_file_info(std::string_view filename, int lineno, std::string str) | ||||
| { | ||||
| 	va_list ap; | ||||
| 	va_start(ap, format); | ||||
| 	std::string fmt = stringf("%s:%d: Info: %s", | ||||
| 			filename.c_str(), lineno, format); | ||||
| 	logv(fmt.c_str(), ap); | ||||
| 	va_end(ap); | ||||
| 	log("%s:%d: Info: %s", filename, lineno, str); | ||||
| } | ||||
| 
 | ||||
| [[noreturn]] | ||||
|  |  | |||
							
								
								
									
										11
									
								
								kernel/log.h
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								kernel/log.h
									
										
									
									
									
								
							|  | @ -124,8 +124,6 @@ extern int log_debug_suppressed; | |||
| void set_verific_logging(void (*cb)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg)); | ||||
| extern void (*log_verific_callback)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg); | ||||
| 
 | ||||
| void log_file_info(const std::string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4)); | ||||
| 
 | ||||
| [[noreturn]] void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2)); | ||||
| [[noreturn]] void log_file_error(const string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4)); | ||||
| [[noreturn]] void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2)); | ||||
|  | @ -175,6 +173,15 @@ void log_file_warning(std::string_view filename, int lineno, FmtString<TypeIdent | |||
| 	log_formatted_file_warning(filename, lineno, fmt.format(args...)); | ||||
| } | ||||
| 
 | ||||
| void log_formatted_file_info(std::string_view filename, int lineno, std::string str); | ||||
| template <typename... Args> | ||||
| void log_file_info(std::string_view filename, int lineno, FmtString<TypeIdentity<Args>...> fmt, const Args &... args) | ||||
| { | ||||
| 	if (log_make_debug && !ys_debug(1)) | ||||
| 		return; | ||||
| 	log_formatted_file_info(filename, lineno, fmt.format(args...)); | ||||
| } | ||||
| 
 | ||||
| static inline void log_suppressed() { | ||||
| 	if (log_debug_suppressed && !log_make_debug) { | ||||
| 		log("<suppressed ~%d debug messages>\n", log_debug_suppressed); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue