You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/12/02 18:34:08 UTC
svn commit: r1209598 - in /subversion/trunk/subversion:
include/private/svn_debug.h libsvn_subr/debug.c
Author: hwright
Date: Fri Dec 2 17:34:06 2011
New Revision: 1209598
URL: http://svn.apache.org/viewvc?rev=1209598&view=rev
Log:
Add a debug macro to print a prop hash.
* subversion/include/private/svn_debug.h
(svn_dbg__print_props, SVN_DBG_PROPS): New.
* subversion/libsvn_subr/debug.c
(DBG_FLAG, print_line, svn_dbg__print_props): New.
(svn_dbg__printf): Implement with print_line().
Modified:
subversion/trunk/subversion/include/private/svn_debug.h
subversion/trunk/subversion/libsvn_subr/debug.c
Modified: subversion/trunk/subversion/include/private/svn_debug.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_debug.h?rev=1209598&r1=1209597&r2=1209598&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_debug.h (original)
+++ subversion/trunk/subversion/include/private/svn_debug.h Fri Dec 2 17:34:06 2011
@@ -37,13 +37,17 @@
extern "C" {
#endif /* __cplusplus */
-/* A couple helper functions for the macros below. */
+/* A few helper functions for the macros below. */
void
svn_dbg__preamble(const char *file, long line, FILE *output);
void
svn_dbg__printf(const char *fmt, ...)
__attribute__((format(printf, 1, 2)));
-
+void
+svn_dbg__print_props(apr_hash_t *props,
+ const char *header_fmt,
+ ...)
+ __attribute__((format(printf, 2, 3)));
/* Print to stdout. Edit this line if you need stderr. */
#define SVN_DBG_OUTPUT stdout
@@ -55,6 +59,7 @@ svn_dbg__printf(const char *fmt, ...)
#ifdef SVN_DBG_QUIET
#define SVN_DBG(ARGS) svn_dbg__preamble(__FILE__, __LINE__, NULL)
+#define SVN_DBG_PROPS(ARGS) svn_dbg__preamble(__FILE__, __LINE__, NULL)
#else
@@ -77,6 +82,9 @@ svn_dbg__printf(const char *fmt, ...)
*/
#define SVN_DBG(ARGS) (svn_dbg__preamble(__FILE__, __LINE__, SVN_DBG_OUTPUT), \
svn_dbg__printf ARGS)
+#define SVN_DBG_PROPS(ARGS) (svn_dbg__preamble(__FILE__, __LINE__, \
+ SVN_DBG_OUTPUT), \
+ svn_dbg__print_props ARGS)
#endif
Modified: subversion/trunk/subversion/libsvn_subr/debug.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/debug.c?rev=1209598&r1=1209597&r2=1209598&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/debug.c (original)
+++ subversion/trunk/subversion/libsvn_subr/debug.c Fri Dec 2 17:34:06 2011
@@ -27,10 +27,13 @@
#include <stdarg.h>
#include "svn_types.h"
+#include "svn_string.h"
#include "private/svn_debug.h"
+#define DBG_FLAG "DBG: "
+
/* This will be tweaked by the preamble code. */
static FILE * volatile debug_output = NULL;
@@ -59,21 +62,52 @@ svn_dbg__preamble(const char *file, long
else
++slash;
- fprintf(output, "DBG: %s:%4ld: ", slash, line);
+ fprintf(output, DBG_FLAG "%s:%4ld: ", slash, line);
}
}
-void
-svn_dbg__printf(const char *fmt, ...)
+static void
+print_line(const char *fmt, va_list ap)
{
FILE *output = debug_output;
- va_list ap;
if (output == NULL || quiet_mode())
return;
- va_start(ap, fmt);
(void) vfprintf(output, fmt, ap);
+}
+
+
+void
+svn_dbg__printf(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ print_line(fmt, ap);
va_end(ap);
}
+
+
+void
+svn_dbg__print_propx(apr_hash_t *props,
+ const char *header_fmt,
+ ...)
+{
+ apr_hash_index_t *hi;
+ va_list ap;
+
+ va_start(ap, header_fmt);
+ print_line(header_fmt, ap);
+ va_end(ap);
+
+ for (hi = apr_hash_first(apr_hash_pool_get(props), props); hi;
+ hi = apr_hash_next(hi))
+ {
+ const char *name = svn__apr_hash_index_key(hi);
+ svn_string_t *val = svn__apr_hash_index_val(hi);
+
+ SVN_DBG((DBG_FLAG " '%s' -> '%s'\n", name, val->data));
+ }
+}