Author: stas
Date: Thu Dec 30 14:34:58 2004
New Revision: 123735

URL: http://svn.apache.org/viewcvs?view=rev&rev=123735
Log:
improve modperl_apr_table_dump to align the fields and make each table 
dump stand out

Modified:
   perl/modperl/trunk/src/modules/perl/modperl_debug.c

Modified: perl/modperl/trunk/src/modules/perl/modperl_debug.c
Url: 
http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_debug.c?view=diff&rev=123735&p1=perl/modperl/trunk/src/modules/perl/modperl_debug.c&r1=123734&p2=perl/modperl/trunk/src/modules/perl/modperl_debug.c&r2=123735
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_debug.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_debug.c Thu Dec 30 14:34:58 2004
@@ -43,22 +43,32 @@
 
     
 #ifdef MP_TRACE
-/* any non-false value for MOD_PERL_TRACE/PerlTrace enables this function */
 void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name)
 {
-    int i;
-    const apr_array_header_t *array;
-    apr_table_entry_t *elts;
+    int i, tmp_len, len = 0;
+    char *fmt;
+    const apr_array_header_t *array = apr_table_elts(table);
+    apr_table_entry_t *elts  = (apr_table_entry_t *)array->elts;
+
+    modperl_trace(MP_FUNC, "*** Contents of table '%s' ***", name);
+    for (i = 0; i < array->nelts; i++) {
+        if (elts[i].key && elts[i].val) {
+            tmp_len = strlen(elts[i].key);
+            if (tmp_len > len) {
+                len = tmp_len;
+            }
+        }
+    }    
+    /* dump the table with keys aligned */
+    fmt = Perl_form(aTHX_ "%%-%ds => %%s", len);
 
-    array = apr_table_elts(table);
-    elts  = (apr_table_entry_t *)array->elts;
-    modperl_trace(MP_FUNC, "Contents of table %s", name);
     for (i = 0; i < array->nelts; i++) {
         if (!elts[i].key || !elts[i].val) {
             continue;
         }
-        modperl_trace(MP_FUNC, "%s => %s", elts[i].key, elts[i].val);
+        modperl_trace(MP_FUNC, fmt, elts[i].key, elts[i].val);
     }    
+    modperl_trace(MP_FUNC, "");
 }
 #endif
 

Reply via email to