summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorPavel Filipenský <pfilipensky@samba.org>2022-08-26 11:42:42 +0200
committerAndreas Schneider <asn@cryptomilk.org>2023-01-26 14:10:36 +0000
commit3b1b37b1cf8f3599f2970cea1d9f0daa36afe4af (patch)
treea67ff3a5f07840f544a7ca1ed7279a5a3bc38357 /lib/util
parent7ba3b1b09de327f77ee11b1c5ba3a77260ce2342 (diff)
downloadsamba-3b1b37b1cf8f3599f2970cea1d9f0daa36afe4af.tar.gz
debug: Call depth: Indent the debug text
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15287 Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/debug.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 04537bdc142..43d5151fbab 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -1635,8 +1635,21 @@ static void format_debug_text( const char *msg )
for( i = 0; msg[i]; i++ ) {
/* Indent two spaces at each new line. */
if(timestamp && 0 == format_pos) {
+ /* Limit the maximum indentation to 20 levels */
+ size_t depth = MIN(20, debug_call_depth);
format_bufr[0] = format_bufr[1] = ' ';
format_pos = 2;
+ /*
+ * Indent by four spaces for each depth level,
+ * but only if the current debug level is >= 8.
+ */
+ if (depth > 0 && debuglevel_get() >= 8 &&
+ format_pos + 4 * depth < FORMAT_BUFR_SIZE) {
+ memset(&format_bufr[format_pos],
+ ' ',
+ 4 * depth);
+ format_pos += 4 * depth;
+ }
}
/* If there's room, copy the character to the format buffer. */