mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
_RUBY_DEBUG_LOG usable anywhere
even if `USE_RUBY_DEBUG_LOG=0`. It becomes `fprintf(stderr, ...)`.
This commit is contained in:
parent
f9eb0d8da2
commit
3bb97e7707
Notes:
git
2025-12-10 01:24:04 +00:00
18
debug.c
18
debug.c
@ -708,4 +708,22 @@ ruby_debug_log_dump(const char *fname, unsigned int n)
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#undef ruby_debug_log
|
||||
void
|
||||
ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "[%s:%d] %s: ", file, line, func_name);
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#endif // #if USE_RUBY_DEBUG_LOG
|
||||
|
||||
@ -88,6 +88,10 @@ void ruby_debug_log(const char *file, int line, const char *func_name, const cha
|
||||
void ruby_debug_log_print(unsigned int n);
|
||||
bool ruby_debug_log_filter(const char *func_name, const char *file_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(...) ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__)
|
||||
|
||||
#if RBIMPL_COMPILER_IS(GCC) && defined(__OPTIMIZE__)
|
||||
# define ruby_debug_log(...) \
|
||||
RB_GNUC_EXTENSION_BLOCK( \
|
||||
@ -97,10 +101,6 @@ bool ruby_debug_log_filter(const char *func_name, const char *file_name);
|
||||
RBIMPL_WARNING_POP())
|
||||
#endif
|
||||
|
||||
// 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(...) ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__)
|
||||
|
||||
#if USE_RUBY_DEBUG_LOG
|
||||
# define RUBY_DEBUG_LOG_ENABLED(func_name, file_name) \
|
||||
(ruby_debug_log_mode && ruby_debug_log_filter(func_name, file_name))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user