summaryrefslogtreecommitdiff
path: root/README.Coding
diff options
context:
space:
mode:
authorChristof Schmitt <cs@samba.org>2015-10-21 11:12:22 -0700
committerJeremy Allison <jra@samba.org>2015-10-21 23:13:17 +0200
commit41fe3cfcb5fa2441da9180e57255a3b7fa23da12 (patch)
tree420dfeae721c86f5908ca52eb95414de10c05bbb /README.Coding
parentb041a589ae680de38f4e9c8c4979c3972a4e7b07 (diff)
downloadsamba-41fe3cfcb5fa2441da9180e57255a3b7fa23da12.tar.gz
README.Coding: Update section about debug macros
Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'README.Coding')
-rw-r--r--README.Coding24
1 files changed, 15 insertions, 9 deletions
diff --git a/README.Coding b/README.Coding
index 9073b77118a..29bad1b1ffc 100644
--- a/README.Coding
+++ b/README.Coding
@@ -417,15 +417,21 @@ The only exception is the test code that depends repeated use of calls
like CHECK_STATUS, CHECK_VAL and others.
-Function names in DEBUG statements
-----------------------------------
+DEBUG statements
+----------------
-Many DEBUG statements contain the name of the function they appear in. This is
-not a good idea, as this is prone to bitrot. Function names change, code
-moves, but the DEBUG statements are not adapted. Use %s and __func__ for this:
+Use these following macros instead of DEBUG:
-Bad Example:
- DEBUG(0, ("strstr_m: src malloc fail\n"));
+DBG_ERR log level 0 error conditions
+DBG_WARNING log level 1 warning conditions
+DBG_NOTICE log level 3 normal, but significant, condition
+DBG_INFO log level 5 informational message
+DBG_DEBUG log level 10 debug-level message
-Good Example:
- DEBUG(0, ("%s: src malloc fail\n", __func__));
+Example usage:
+
+DBG_ERR("Memory allocation failed\n");
+DBG_DEBUG("Received %d bytes\n", count);
+
+The messages from these macros are automatically prefixed with the
+function name.