Am Dienstag 02 Januar 2007 20:12 schrieb Marcel Holtmann:
> > > the more I looked into this, the more I think this stuff needs a
> > > massive cleanup. It is a grown debug structure and it is not really
> > > helpful and simple at the moment. Any ideas or should I go with your
> > > patch for now?
> >
> > Grown? I think it's pretty simple as it only contains two macros. But
> > maybe you have a deeper insight. What do you think is broken with the
> > current one? You may as well call log_debug() something else, I just
> > couldn't think of another name as the debug output is its main usage.
>
> before 1.0.0 we merged various debug possibilities and I don't think
> that it is very clean at the moment. However I have no idea what is the
> best debug method for a library. So I am open for suggestions.

The below is UNTESTED and an idea how to do it in a lib.

Let the application set whatever it wants:
void (*obex_debug_func)(const char* format,...);
void OBEX_SetDebugFunc(void (*func)(const char* format, ...)) {
        obex_debug_func = func;
}

Call that from an lib-internal debug function.
As an addition, the debug function call wrapper can check for
obex_debug_func == NULL
to actually trigger debug output. Thus, library debug output can have a 
runtime dependency on application debug settings:
extern void (*obex_debug_func)(const char* format,...);
#define log_debug(format,args...) \
        if(obex_debug_func)obex_debug_func(format, ##args )

Default could be none (you could drop the configure option alltogether) or an 
fprintf wrapper:
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
void obex_defaultDebugFunc(const char* format, ...) {
        va_list ap;
        assert(format != NULL);
        va_start(format,ap);
        vfprintf(stderr,format,ap);
        va_end(ap);
}

Now, you can assign that as default in OBEX_Init():
OBEX_SetDebugFunc(obex_defaultDebugFunc);

If the application wants something else, it can do whatever it wants and you 
can completely drop the syslog stuff.
Syslog is useless for a user anyway as the log files are usually not readable 
for normal users. If still want syslog, the vsyslog() function exists.

HS

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to