libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Provide a means to activate dynamically the debug traces


From: Akim Demaille
Subject: Re: Provide a means to activate dynamically the debug traces
Date: Wed, 14 Jan 2009 11:16:58 +0100


Le 10 janv. 09 à 22:25, Ralf Wildenhues a écrit :

So what do you recommend to store persistent information?  A function
that returns some static variable (sort of a singleton)?  Or an
additional argument everywhere (gee...).  Maybe I can do it using
advices to hand over the verbosity flags, but that does sound like a
nuisance for the API.

A lt_dlget* and a lt_dlset* function, if the user needs to be able to
provide a type.  Don't provide the user with a direct pointer if you
don't have to.

Note that I didn't say global variables are bad, although they are
obviously bad, too, for two reasons: slow access, and, well, globality.
Assume that you write a library that uses ltdl internally, and I use
your library in a program that also links against a completely different library that also uses ltdl. You'll most likely not want interference.
Well, in your case I'm not so sure.  But if not, then adding a module
loading advisor to change verbosity would seem appropriate.

I thought about this, and I think that the best option would be to have a callback function with a signature more or less like:

void log(void* user_data, level_type level, const char* format, ...);

(or maybe return an int in the spirit of ltdl to count errors?)

It could be given as a new kind of advise for the callback, and the callback user data. It should cover all the needs, and should make it quite easy for C++ users to have wrappers that use the user_data to pass whatever log object they might use.

It is no longer ltdl that would decide whether to record or not the message, the level is given to the user. I'm ambivalent wrt level: should it be a magnitude, or a bit-field for the various kinds of event?

One problem with the advise-based approach is that not everything works via advisors. For a start lt_init does not. It also makes it somewhat inconvenient for user who decided to use the basic interface to have logs easily.

So maybe it should rather be handled as a global inside ltdl, rather than an additional argument passed argument, possibly passed to lt_dlinit*, or even before lt_dlinit.

What do you think about it?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]