[GRASS-dev] Re: g.rename consolidation

Hamish hamish_nospam at yahoo.com
Mon Feb 26 01:15:10 EST 2007


Martin Landa wrote:
> is now also printed when GRASS_VERBOSITY is "1". I vote for using
> *G_message*, not fprintf() for this puspose.
..
> The verbosity level "1" should be used only for G_percent(), not for
> "standard" messages at all.

I don't see any problem with allowing modules to use fine grain
verbosity rules. How does it hurt? The verbosity concept is more
abstract than percents and messages.

right now we have:

 very vebose == 3 
 normal      == 2 
 brief       == 1
 silent but not mute == 0
and
 mute        == 2>&1 > /dev/null

why disallow brief?


> OK, it would be also useful to have G_message_no_nl() which does not
> print new-line character at the of the message. I am not sure how to
> derive these functions from the existing G_message() fn.

Easy, don't bother with another new libgis fn. The no newline situation*
is better handled by fprintf(stdout, ) + fflush(stdout). AFAIK
fprintf(stderr, ..) will only print complete \n terminated lines, and so
you can only output:

[*]  "Working: " [code+time] " done.\n"

using stdout. And stdout works fine, so why reimpliment all of glibc as
G_() fns? Better to just G_() fns when there are portability issues or
it helps to clean the code a lot, eg G_debug().

If fprintf(stdout,..) is the most appropriate thing to use, then don't
be afraid to use it.

I agree G_message() removing the ability to add newlines can be
limiting. But I find the stripping of internal whitespace more annoying
as you can't work around it ("  " -> " ").

Glynn Clements wrote:
> There needs to be a new function for messages which allows specifying
> the verbosity level.
> Rather than individual modules having to do:
> 	if (G_verbose() >= level)
> 		G_message(...);
> 
> they would do e.g.:
> 	G_message_ex(level, ...);
> 
> The new function would check the verbosity level.
> The current mechanism is just making the code messy.

I agree; be like G_debug(). I'd prefer a nicer name than G_message_ex().

e.g.
G_msg(MSG_STD, "Look at your shoes\n<%s>", string);

gis.h
#define MSG_VRB 3
#define MSG_STD 2
#define MSG_BRF 1
#define MSG_QET 0

\n is appened to the string and the string is not stripped of whitespace
chars (multiple spaces, \t, \n). i.e. don't censor the coder.


Hamish




More information about the grass-dev mailing list