summaryrefslogtreecommitdiff
path: root/include/my_dbug.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/my_dbug.h')
-rw-r--r--include/my_dbug.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/my_dbug.h b/include/my_dbug.h
index d56033ab025..ba9e8a025d7 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
- Copyright (C) 2000-2011 Monty Program Ab
+ Copyright (C) 2000, 2017, MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ extern void _db_set_init_(const char *control);
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
struct _db_stack_frame_ *_stack_frame_);
extern void _db_return_(struct _db_stack_frame_ *_stack_frame_);
-extern void _db_pargs_(uint _line_,const char *keyword);
+extern int _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_(const char *format,...)
ATTRIBUTE_FORMAT(printf, 1, 2);
extern void _db_dump_(uint _line_,const char *keyword,
@@ -91,7 +91,7 @@ extern const char* _db_get_func_(void);
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
- do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
+ do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (a1)
@@ -193,8 +193,18 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
#define DBUG_SYNC_POINT(lock_name,lock_timeout)
#endif /* EXTRA_DEBUG */
-#ifdef __cplusplus
+#ifdef __cplusplus
}
+# ifdef DBUG_OFF
+# define DBUG_LOG(keyword, v) do {} while (0)
+# else
+# include <sstream>
+# define DBUG_LOG(keyword, v) do { \
+ if (_db_pargs_(__LINE__, keyword)) { \
+ std::ostringstream _db_s; _db_s << v; \
+ _db_doprnt_("%s", _db_s.str().c_str()); \
+ }} while (0)
+# endif
#endif
#endif /* _my_dbug_h */