25
25
be used in release code. One of the reasons to avoid this code in release
26
26
builds is that this code is not thread-safe. */
27
27
#include <stdarg.h>
30
#include <apr_pools.h>
31
#include <apr_strings.h>
29
32
#include "svn_types.h"
33
#include "svn_string.h"
35
#ifndef SVN_DBG__PROTOTYPES
36
#define SVN_DBG__PROTOTYPES
31
38
#include "private/svn_debug.h"
41
#define DBG_FLAG "DBG: "
34
43
/* This will be tweaked by the preamble code. */
44
static const char *debug_file = NULL;
45
static long debug_line = 0;
35
46
static FILE * volatile debug_output = NULL;
56
67
slash = strrchr(file, '\\');
69
debug_file = slash + 1;
62
fprintf(output, "DBG: %s:%4ld: ", slash, line);
68
svn_dbg__printf(const char *fmt, ...)
77
/* Print a formatted string using format FMT and argument-list AP,
78
* prefixing each line of output with a debug header. */
80
debug_vprintf(const char *fmt, va_list ap)
70
82
FILE *output = debug_output;
83
char prefix[80], buffer[1000];
73
87
if (output == NULL || quiet_mode())
90
n = apr_snprintf(prefix, sizeof(prefix), DBG_FLAG "%s:%4ld: ",
91
debug_file, debug_line);
92
assert(n < sizeof(prefix) - 1);
93
n = apr_vsnprintf(buffer, sizeof(buffer), fmt, ap);
94
assert(n < sizeof(buffer) - 1);
97
char *newline = strchr(s, '\n');
101
fputs(prefix, output);
109
while (*s); /* print another line, except after a final newline */
114
svn_dbg__printf(const char *fmt, ...)
76
118
va_start(ap, fmt);
77
(void) vfprintf(output, fmt, ap);
119
debug_vprintf(fmt, ap);
125
svn_dbg__print_props(apr_hash_t *props,
126
const char *header_fmt,
129
/* We only build this code if SVN_DEBUG is defined. */
132
apr_hash_index_t *hi;
135
va_start(ap, header_fmt);
136
debug_vprintf(header_fmt, ap);
141
svn_dbg__printf(" (null)\n");
145
for (hi = apr_hash_first(apr_hash_pool_get(props), props); hi;
146
hi = apr_hash_next(hi))
148
const char *name = svn__apr_hash_index_key(hi);
149
svn_string_t *val = svn__apr_hash_index_val(hi);
151
svn_dbg__printf(" '%s' -> '%s'\n", name, val->data);
153
#endif /* SVN_DEBUG */