Debug: indent ACL and expreassion tracing by evaluation depth
[exim.git] / src / src / debug.c
index 8f9359b15837b9702a9e6616d3cd583bdd21e6d5..3cd6d0c92e0afb4975114d3b9fab5e7b058b1d29 100644 (file)
@@ -137,7 +137,7 @@ debug_printf("%s uid=%ld gid=%ld euid=%ld egid=%ld\n", s,
 *************************************************/
 
 /* There are two entries, one for use when being called directly from a
-function with a variable argument list.
+function with a variable argument list, one for prepending an indent.
 
 If debug_pid is nonzero, print the pid at the start of each line. This is for
 tidier output when running parallel remote deliveries with debugging turned on.
@@ -146,6 +146,28 @@ get interleaved. Since some calls to debug_printf() don't end with newline,
 we save up the text until we do get the newline.
 Take care to not disturb errno. */
 
+
+/* Debug printf indented by ACL nest depth */
+void
+debug_printf_indent(const char * format, ...)
+{
+va_list ap;
+unsigned depth = acl_level + expand_level, i;
+
+if (!debug_file) return;
+if (depth > 0)
+  {
+  for (i = depth >> 2; i > 0; i--)
+    fprintf(debug_file, "   .");
+  fprintf(debug_file, "%*s", depth & 3, "");
+  }
+
+va_start(ap, format);
+debug_vprintf(format, ap);
+va_end(ap);
+}
+
+
 void
 debug_printf(const char *format, ...)
 {