Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_config.h ewl_debug.h ewl_misc.c ewl_misc.h 


Log Message:
- try to indent the debug output a bit so it's easier to read

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_config.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_config.h        23 Oct 2005 17:30:56 -0000      1.3
+++ ewl_config.h        22 Nov 2005 17:28:15 -0000      1.4
@@ -16,6 +16,7 @@
        struct {
                int             enable;
                int             level;
+               int             indent_lvl;
        } debug;
        struct {
                int             font_cache;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_debug.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_debug.h 23 Oct 2005 17:02:18 -0000      1.9
+++ ewl_debug.h 22 Nov 2005 17:28:15 -0000      1.10
@@ -2,13 +2,17 @@
 #define __EWL_DEBUG_H__
 
 #include "ewl-config.h"
+#include "ewl_misc.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define DLEVEL_UNSTABLE 1
 #define DLEVEL_TESTING 10
 #define DLEVEL_STABLE 20
 
-inline void     ewl_print_warning(void);
-inline void    ewl_segv(void);
+inline void ewl_print_warning(void);
+inline void ewl_segv(void);
 
 #define DEBUG 1
 
@@ -18,8 +22,11 @@
 { \
        if (ewl_config.debug.enable && (ewl_config.debug.level >= (lvl))) \
          { \
-               fprintf(stderr, " --> %s:%i\tEntering %s();\n", \
-                       __FILE__, __LINE__, __FUNCTION__); \
+               char *indent = ewl_debug_get_indent(); \
+               ewl_config.debug.indent_lvl ++; \
+               fprintf(stderr, "%s--> %s:%i\tEntering %s();\n", \
+                       indent, __FILE__, __LINE__, __FUNCTION__); \
+               FREE(indent); \
          } \
 }
 
@@ -27,8 +34,12 @@
 { \
        if (ewl_config.debug.enable && (ewl_config.debug.level >= (lvl))) \
          { \
-               fprintf(stderr, "<--  %s:%i\tLeaving  %s();\n", \
-                       __FILE__, __LINE__, __FUNCTION__); \
+               char *indent; \
+               ewl_config.debug.indent_lvl --; \
+               indent = ewl_debug_get_indent(); \
+               fprintf(stderr, "%s<--  %s:%i\tLeaving  %s();\n", \
+                       indent, __FILE__, __LINE__, __FUNCTION__); \
+               FREE(indent); \
          } \
 }
 
@@ -37,8 +48,12 @@
        DLEAVE_FUNCTION(lvl); \
        if (ewl_config.debug.enable && (ewl_config.debug.level >= (lvl))) \
          { \
-               fprintf(stderr, "<--  %s:%i\tReturn in %s();\n", \
-                       __FILE__, __LINE__, __FUNCTION__); \
+               char *indent; \
+               ewl_config.debug.indent_lvl --; \
+               indent = ewl_debug_get_indent(); \
+               fprintf(stderr, "%s<--  %s:%i\tReturn in %s();\n", \
+                       indent, __FILE__, __LINE__, __FUNCTION__); \
+               FREE(indent); \
          } \
        return; \
 }
@@ -48,8 +63,12 @@
        DLEAVE_FUNCTION(lvl); \
        if (ewl_config.debug.enable && (ewl_config.debug.level >= (lvl))) \
          { \
-               fprintf(stderr, "<--  %s:%i\tReturning %p in %s();\n", \
-                       __FILE__, __LINE__, (void *) (ptr), __FUNCTION__); \
+               char *indent; \
+               ewl_config.debug.indent_lvl --; \
+               indent = ewl_debug_get_indent(); \
+               fprintf(stderr, "%s<--  %s:%i\tReturning %p in %s();\n", \
+                       indent, __FILE__, __LINE__, (void *) (ptr), 
__FUNCTION__); \
+               FREE(indent); \
          } \
        return (void *)(ptr); \
 }
@@ -59,8 +78,12 @@
        DLEAVE_FUNCTION(lvl); \
        if (ewl_config.debug.enable && (ewl_config.debug.level >= (lvl))) \
          { \
-               fprintf(stderr, "<--  %s:%i\tReturning %f in %s();\n", \
-                       __FILE__, __LINE__, (float) (num), __FUNCTION__); \
+               char *indent; \
+               ewl_config.debug.indent_lvl --; \
+               indent = ewl_debug_get_indent(); \
+               fprintf(stderr, "%s<--  %s:%i\tReturning %f in %s();\n", \
+                       indent, __FILE__, __LINE__, (float) (num), 
__FUNCTION__); \
+               FREE(indent); \
          } \
        return num; \
 }
@@ -70,8 +93,12 @@
        DLEAVE_FUNCTION(lvl); \
        if (ewl_config.debug.enable && (ewl_config.debug.level >= (lvl))) \
          { \
-               fprintf(stderr, "<--  %s:%i\tReturning %i in %s();\n", \
-                       __FILE__, __LINE__, (int) (num), __FUNCTION__); \
+               char *indent; \
+               ewl_config.debug.indent_lvl --; \
+               indent = ewl_debug_get_indent(); \
+               fprintf(stderr, "%s<--  %s:%i\tReturning %i in %s();\n", \
+                       indent, __FILE__, __LINE__, (int) (num), __FUNCTION__); 
\
+               FREE(indent); \
          } \
        return num; \
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_misc.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- ewl_misc.c  18 Nov 2005 05:13:58 -0000      1.27
+++ ewl_misc.c  22 Nov 2005 17:28:15 -0000      1.28
@@ -939,7 +939,8 @@
        DRETURN_INT(ecore_list_nodes(destroy_list), DLEVEL_STABLE);
 }
 
-int ewl_ecore_exit(void *data __UNUSED__, int type __UNUSED__,
+int
+ewl_ecore_exit(void *data __UNUSED__, int type __UNUSED__,
                                        void *event __UNUSED__)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -950,7 +951,8 @@
 }
 
 #ifdef DEBUG_MALLOCDEBUG
-char *strdup(const char *str)
+char *
+strdup(const char *str)
 {
        char *dst = malloc(strlen(str) + 1);
        if (dst)
@@ -960,3 +962,16 @@
 }
 #endif
 
+char *
+ewl_debug_get_indent(void)
+{
+       char *indent = NULL;
+       
+       if (ewl_config.debug.indent_lvl < 0)
+               ewl_config.debug.indent_lvl = 0;
+
+       indent = calloc((ewl_config.debug.indent_lvl * 2) + 2, sizeof(char *)); 
+       memset(indent, ' ', (ewl_config.debug.indent_lvl * 2) + 1);
+       return indent;
+}
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_misc.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_misc.h  18 Nov 2005 14:32:43 -0000      1.9
+++ ewl_misc.h  22 Nov 2005 17:28:15 -0000      1.10
@@ -37,6 +37,7 @@
 unsigned int    ewl_engine_mask_get();
 void            ewl_evas_destroy(Evas *evas);
 void            ewl_evas_object_destroy(Evas_Object *obj);
+char          *ewl_debug_get_indent(void);
 
 #undef DEBUG_MALLOCDEBUG
 #ifdef DEBUG_MALLOCDEBUG




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to