Index:
[thread]
[date]
[subject]
[author]
From: WHS <wouters@cistron.nl>
To : ggi-develop@eskimo.com
Date: Sat, 05 Sep 1998 13:18:18 +0200
Re: Improved debugging system for libggi
Marcus Sundberg wrote:
>
> Andrew Apted wrote:
> >
> > WHS writes:
> >
> > > Isn't it much nicer to use debug prefixes (inxfixes, postfixes) like I
> > > use in gsi, e.g. use GGI_DEBUG_CORE = n to give level n output of the
> > > core section, GGI_DEBUG_EVENTS=0 switches off event messages.
> >
> > That sounds better to me.
> >
> > > going to be a nightmare trying to remember which bit was assigned to
> > > what part of libggi.
>
> Well, this scheme was designed to make debugging faster for people
> that know what they're doing. Mere mortals just set GGI_DEBUG to
> 255 and post th eoutput to the list.
I know what I'm doing and I know this is a kludgy system, nothing to do
with knowing/not knowing.
As I said, you're never going to remember those bits and having to add
bits to get output is a nuisance at the very least.
> If you want more different debuglevels I won't object to it, but
> please keep the ability to turn on full debugging for different
> sections with a mask.
I'm not going to change libggi, at least until gsi 0.7 is ready, but as
you're doing these debug changes you should consider doing it. It's
really a lot easier. I've attached debug.h I use at the moment.
Regards,
Wouter
/* Debug definitions
*
* By W.H.Scholten 1996,1997,1998
*
* This file is public domain
*/
//Inspector Gadget is ALWAYS on duty
/*---------------------------------------------------------------------------*
* use the environment variable DEBUG_LEVEL to set the level of
information
* you want to see (unset or 0 gives no output)
* i.e. DEBUG_LEVEL=1, export DEBUG_LEVEL for bash
* Hardcoding a debug level to 11,12,13 will always give level 1,2,3
output
* DEBUG_PREFIX can be set before the #include <gsi/debug.h> in any file
to
* control output of different program sections with different
environment
* variables.
*---------------------------------------------------------------------------*/
#ifndef _WHS_DEBUG_H
#define _WHS_DEBUG_H
#undef DEB
#undef DEB1
#undef DEB2
#undef DEB3
#undef ASSERT
#ifdef DEBUG
#include <stdlib.h>
# ifndef DEBUG_LEVEL
# define DEBUG_LEVEL 1
# endif
# ifndef DEBUG_PREFIX
# define DEBUG_PREFIX ""
# endif
static int _whs_debug(int level) {
static int whs_dbl=-1;
if (whs_dbl<0) {
char *whs_env;
whs_env = getenv("DEBUG_LEVEL");
if (whs_env !=NULL) whs_dbl=atol(whs_env);
else whs_dbl=0;
whs_env = getenv(DEBUG_PREFIX"DEBUG_LEVEL");
if (whs_env !=NULL) {
int whs_prefix_dbl = atol(whs_env);
if (whs_prefix_dbl > whs_dbl) whs_dbl = whs_prefix_dbl;
}
}
return (whs_dbl>=level);
}
# define DEB(x) x
# define DEB1(x) { if (_whs_debug(1) ) { x; } }
# define DEB2(x) { if (_whs_debug(2) ) { x; } }
# define DEB3(x) { if (_whs_debug(3) ) { x; } }
# define prt printf
# define fprt fprintf
# define ASSERT(expr) { if (!(expr)) { fprintf(stderr, "Assertion
failed: %s, file %s, line %d\n", #expr, __FILE__, __LINE__); exit (0); }
}
# define ENSURE(expr) ASSERT(expr)
#else
# define DEB(x)
# define DEB1(x)
# define DEB2(x)
# define DEB3(x)
# define ASSERT(expr)
# define ENSURE(expr)
#endif
//Show me the way, o glorious inspector.
#endif /* _WHS_DEBUG_H */
Index:
[thread]
[date]
[subject]
[author]