diff options
author | Koichi Sasada <[email protected]> | 2020-08-02 04:24:47 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-08-02 04:24:47 +0900 |
commit | b4f58ea3008e3e86bdc931407c68c6e0497ef078 (patch) | |
tree | 23072053052fa229d957acda142af4a9d1fb573a /vm_debug.h | |
parent | f7cf600c8ba483d389ea400071aa2aea2e5a57e0 (diff) |
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).
Diffstat (limited to 'vm_debug.h')
-rw-r--r-- | vm_debug.h | 14 |
1 files changed, 12 insertions, 2 deletions
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, ...) |