summaryrefslogtreecommitdiff
path: root/lib/util/debug.h
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-05-26 15:55:12 +1200
committerAndrew Bartlett <abartlet@samba.org>2022-06-17 01:28:30 +0000
commit1a6890a94d23ad15bddd07f2ed1dc5fa68d4cef1 (patch)
tree59333c36a51121bc60ec9efae3a88e03bf662686 /lib/util/debug.h
parentb94c805783ecb2ed5dccdeb3747575aec579883b (diff)
downloadsamba-1a6890a94d23ad15bddd07f2ed1dc5fa68d4cef1.tar.gz
debug: add DBG_DEV()
This can be a useful macro when you are trying to track the behaviour of one process out of the dozens that samba starts up, and when your interest is in following it over time, not necessarily in a single stack. In DEVELOPER mode, if you call 'debug_developer_enable()' in the process you're following, then any instances of DBG_DEV() will work like DBG_ERR(), also adding ":DEV:12345:" where "12345" is the pid of th current process. Within debug.c itself, the macro always writes to stderr, because the debug.c functions are not all reentrant. When not in DEVELOPER MODE, the macro evaluates to nothing. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/util/debug.h')
-rw-r--r--lib/util/debug.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/util/debug.h b/lib/util/debug.h
index 9aeec853e64..9f902863527 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -237,6 +237,16 @@ void debuglevel_set_class(size_t idx, int level);
&& (dbgtext("%s: ", __func__)) \
&& (dbgtext body) )
+
+#ifdef DEVELOPER
+#define DBG_DEV(...) \
+ (void)( (debug_developer_enabled()) \
+ && (dbgtext("%s:DEV:%d: ", __func__, getpid())) \
+ && (dbgtext(__VA_ARGS__)) )
+#else
+#define DBG_DEV(...) /* DBG_DEV was here */
+#endif
+
/*
* Debug levels matching RFC 3164
*/
@@ -329,6 +339,9 @@ bool debug_get_output_is_stderr(void);
bool debug_get_output_is_stdout(void);
void debug_schedule_reopen_logs(void);
char *debug_list_class_names_and_levels(void);
+bool debug_developer_enabled(void);
+void debug_developer_enable(void);
+void debug_developer_disable(void);
typedef void (*debug_callback_fn)(void *private_ptr, int level, const char *msg);