From b4f58ea3008e3e86bdc931407c68c6e0497ef078 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Sun, 2 Aug 2020 04:24:47 +0900 Subject: support multiple filters by RUBY_DEBUG_LOG_FILTER Now you can specify multiple filters for RUBY_DEBUG_LOG output by RUBY_DEBUG_LOG_FILTER=a,b,c (in this case, logs that the function name contains a, b or c). --- vm_debug.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'vm_debug.h') diff --git a/vm_debug.h b/vm_debug.h index 9b4fb3db7b..a3631c0309 100644 --- a/vm_debug.h +++ b/vm_debug.h @@ -89,14 +89,24 @@ extern enum ruby_debug_log_mode { void ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...); void ruby_debug_log_print(unsigned int n); +bool ruby_debug_log_filter(const char *func_name); // convenient macro to log even if the USE_RUBY_DEBUG_LOG macro is not specified. // You can use this macro for temporary usage (you should not commit it). #define _RUBY_DEBUG_LOG(fmt, ...) ruby_debug_log(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__) #if USE_RUBY_DEBUG_LOG -#define RUBY_DEBUG_LOG(fmt, ...) do { if (ruby_debug_log_mode) ruby_debug_log(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__); } while (0) -#define RUBY_DEBUG_LOG2(file, line, fmt, ...) do { if (ruby_debug_log_mode) ruby_debug_log(file, line, __func__, fmt, __VA_ARGS__); } while (0) + +#define RUBY_DEBUG_LOG(fmt, ...) do { \ + if (ruby_debug_log_mode && ruby_debug_log_filter(__func__)) \ + ruby_debug_log(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__); \ +} while (0) + +#define RUBY_DEBUG_LOG2(file, line, fmt, ...) do { \ + if (ruby_debug_log_mode && ruby_debug_log_filter(__func__)) \ + ruby_debug_log(file, line, __func__, fmt, __VA_ARGS__); \ +} while (0) + #else // do nothing #define RUBY_DEBUG_LOG(fmt, ...) -- cgit v1.2.1