[GRASS-dev] Re: g.rename consolidation

Martin Landa landa.martin at gmail.com
Mon Feb 26 03:23:53 EST 2007


Hi Hamish,

2007/2/26, Hamish <hamish_nospam at yahoo.com>:
> 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 nice to describe *fixed* rules for module verbosity
level, e.g. on the GRASS-wiki and use them when coding new module or
patching the old one. It will prevent from inconsistency along GRASS
modules in the future.

>
> > 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:

I think it is better to use G_message() (or more advanced G_ fn) for
*all* module messages. fprintf (stdout, ) should be used for the
*output* not for the messages. It mixed two different things together
which would be better to separate. I think that mixing messages and
module output would cause problems in the future. All message should
be controlled by GRASS_VERBOSE level or GRASS_MESSAGE_FORMAT.

> [*]  "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.

It makes sense to me. Maybe we need more advanced fn then G_message().

>
> Hamish
>

Martin

-- 
Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *




More information about the grass-dev mailing list