On 26.07.2012 11:30, Joerg Wunsch wrote:
As Axel Wachtler wrote:

My intention would be to move the "if(verbose>SOMETHING)" into
the macro itself, this would make the code easier to read.

PRINT(WARNING, "foo=%d\n", 42);

Sounds reasonable.

I'd call it MESSAGE() rather than PRINT().

Agreed, MESSAGE is the better name for this Macro.

Note that there's currently a distintion between -q and -qq.  The
latter makes it really quite regarding all informational messages,
while a single -q IMHO only silences the progress bar but still
displays some other messages.

Ok, I will make the patch so that the current output of avrdude is
retained as it is now.

so I would prefer a callback function that gets a simple string and
all the formatting is done in the central printing function.

It's OK, but I think the callback function should also get the
"severity" indication (rather than performing the yes/no decision
inside a macro or such), so it can decide by itself whether it has to
act upon the message, and how.  E.g., a GUI sitting on top of the
shared lib might opt to display error or warning messages in a popup,
informational messages in a status window, and log debugging messages
only internally, to be displayed upon request of the user (or to be
written in to a file).

Sounds good, the function called by MESSAGE() will always generate the string and pass the string together with the severity parameter to the user callback.

This has also the advantage that the current global variables "quite"
and "verbose" could be made static to the existing main.c, and no
longer need to be known inside the library.

Sounds good.

Cheers, Axel

_______________________________________________
avrdude-dev mailing list
avrdude-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

Reply via email to