[GRASS-dev] G_program_name to every message

Hallo,

I think it would be nice, if G_message, G_warning and G_fatal_error
would print module name at the beginning of the message.

If the modules are used in scripts, it is sometimes difficult to
identify, which C-module, used in the script, caused some problem or is
printing the message. This is the case for e.g. r.report (file stats.c)
too.

What about adding G_program_name(); to every message, so that

    G_message("Hallo, world!");
    
would produce

    g.module: Hallo, world!

and
    G_warning("Hallo, world!"); -> WARNING: g.module: Hallo, world!

??

The question is, how to do it... Imho the best place is printf_error();
in error.c

What do you think?

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

On Sun, 2007-01-07 at 19:00 +0100, Jachym Cepicky wrote:

Hallo,

I think it would be nice, if G_message, G_warning and G_fatal_error
would print module name at the beginning of the message.

If the modules are used in scripts, it is sometimes difficult to
identify, which C-module, used in the script, caused some problem or is
printing the message. This is the case for e.g. r.report (file stats.c)
too.

What about adding G_program_name(); to every message, so that

    G_message("Hallo, world!");
    
would produce

    g.module: Hallo, world!

Why? This amounts to spam, IMHO. Some module names are 30 characters
wide (I'm looking at you, r.li)! That's nearly half the terminal
length.

r.li's modules need to be renamed in keeping with other modules (mixed
case, length, etc.). I do not envy anyone who has to use them without
tab-completion or similar.

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

On Jan 7, 2007, at 4:17 PM, Brad Douglas wrote:

On Sun, 2007-01-07 at 19:00 +0100, Jachym Cepicky wrote:

Hallo,

I think it would be nice, if G_message, G_warning and G_fatal_error
would print module name at the beginning of the message.

If the modules are used in scripts, it is sometimes difficult to
identify, which C-module, used in the script, caused some problem or is
printing the message. This is the case for e.g. r.report (file stats.c)
too.

What about adding G_program_name(); to every message, so that

    G_message("Hallo, world!");

would produce

    g.module: Hallo, world!

Why? This amounts to spam, IMHO. Some module names are 30 characters
wide (I'm looking at you, r.li)! That's nearly half the terminal
length.

r.li's modules need to be renamed in keeping with other modules (mixed
case, length, etc.). I do not envy anyone who has to use them without
tab-completion or similar.

this was discussed already and new names were proposed - Serena was probably
just waiting to get her CVS access approved?
Serena, now that you have the access can you please change the names -
it would be good to do it ASAP before people start using the long names in their scripts.

as for the message, I tend to agree with jachym on this one, I think
it would be useful to have the module name printed along with the message -
except for r.li* the modules have quite reasonable names.

Thanks, Helena

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

Hi Jachym. Great idea. I would condition that on the debug environment
variable. You might even consider adding __FILE__ and __LINE__
references then.

Daniel.

On 1/7/07, Jachym Cepicky <jachym.cepicky@centrum.cz> wrote:

Hallo,

I think it would be nice, if G_message, G_warning and G_fatal_error
would print module name at the beginning of the message.

If the modules are used in scripts, it is sometimes difficult to
identify, which C-module, used in the script, caused some problem or is
printing the message. This is the case for e.g. r.report (file stats.c)
too.

What about adding G_program_name(); to every message, so that

    G_message("Hallo, world!");

would produce

    g.module: Hallo, world!

and
    G_warning("Hallo, world!"); -> WARNING: g.module: Hallo, world!

??

The question is, how to do it... Imho the best place is printf_error();
in error.c

What do you think?

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFFoTUoyKt0uAjU4I8RAklPAJ9nv9alWvXazqqsxzacKR0+uJA5lwCfTKxi
ZHX8m3KrvQyWQqUI3V/QRwQ=
=ns2o
-----END PGP SIGNATURE-----

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
-- Daniel Calvelo Aros

No. The only place that is appropriate is G_debug(). Average users
could care less about that information and will likely complain about
it.

On Sun, 2007-01-07 at 20:42 -0500, Daniel Calvelo wrote:

Hi Jachym. Great idea. I would condition that on the debug environment
variable. You might even consider adding __FILE__ and __LINE__
references then.

Daniel.

On 1/7/07, Jachym Cepicky <jachym.cepicky@centrum.cz> wrote:
> Hallo,
>
> I think it would be nice, if G_message, G_warning and G_fatal_error
> would print module name at the beginning of the message.
>
> If the modules are used in scripts, it is sometimes difficult to
> identify, which C-module, used in the script, caused some problem or is
> printing the message. This is the case for e.g. r.report (file stats.c)
> too.
>
> What about adding G_program_name(); to every message, so that
>
> G_message("Hallo, world!");
>
> would produce
>
> g.module: Hallo, world!
>
> and
> G_warning("Hallo, world!"); -> WARNING: g.module: Hallo, world!
>
> ??
>
> The question is, how to do it... Imho the best place is printf_error();
> in error.c
>
> What do you think?

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

Oops. I missed a key word when I read it: "debug". Sorry.

On Sun, 2007-01-07 at 18:14 -0800, Brad Douglas wrote:

No. The only place that is appropriate is G_debug(). Average users
could care less about that information and will likely complain about
it.

On Sun, 2007-01-07 at 20:42 -0500, Daniel Calvelo wrote:
> Hi Jachym. Great idea. I would condition that on the debug environment
> variable. You might even consider adding __FILE__ and __LINE__
> references then.
>
> Daniel.
>
> On 1/7/07, Jachym Cepicky <jachym.cepicky@centrum.cz> wrote:
> > Hallo,
> >
> > I think it would be nice, if G_message, G_warning and G_fatal_error
> > would print module name at the beginning of the message.
> >
> > If the modules are used in scripts, it is sometimes difficult to
> > identify, which C-module, used in the script, caused some problem or is
> > printing the message. This is the case for e.g. r.report (file stats.c)
> > too.
> >
> > What about adding G_program_name(); to every message, so that
> >
> > G_message("Hallo, world!");
> >
> > would produce
> >
> > g.module: Hallo, world!
> >
> > and
> > G_warning("Hallo, world!"); -> WARNING: g.module: Hallo, world!
> >
> > ??
> >
> > The question is, how to do it... Imho the best place is printf_error();
> > in error.c
> >
> > What do you think?

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

On 1/7/07, Brad Douglas <rez@touchofmadness.com> wrote:

Oops. I missed a key word when I read it: "debug". Sorry.

:slight_smile: No harm. Indeed, for debugging purposes, it may give some extra
information at little coding cost.

On Sun, 2007-01-07 at 18:14 -0800, Brad Douglas wrote:
> No. The only place that is appropriate is G_debug(). Average users
> could care less about that information and will likely complain about
> it.
>
> On Sun, 2007-01-07 at 20:42 -0500, Daniel Calvelo wrote:
> > Hi Jachym. Great idea. I would condition that on the debug environment
> > variable. You might even consider adding __FILE__ and __LINE__
> > references then.
> >
> > Daniel.
> >
> > On 1/7/07, Jachym Cepicky <jachym.cepicky@centrum.cz> wrote:
> > > Hallo,
> > >
> > > I think it would be nice, if G_message, G_warning and G_fatal_error
> > > would print module name at the beginning of the message.
> > >
> > > If the modules are used in scripts, it is sometimes difficult to
> > > identify, which C-module, used in the script, caused some problem or is
> > > printing the message. This is the case for e.g. r.report (file stats.c)
> > > too.
> > >
> > > What about adding G_program_name(); to every message, so that
> > >
> > > G_message("Hallo, world!");
> > >
> > > would produce
> > >
> > > g.module: Hallo, world!
> > >
> > > and
> > > G_warning("Hallo, world!"); -> WARNING: g.module: Hallo, world!
> > >
> > > ??
> > >
> > > The question is, how to do it... Imho the best place is printf_error();
> > > in error.c
> > >
> > > What do you think?

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

--
-- Daniel Calvelo Aros

Brad Douglas wrote:

> Hi Jachym. Great idea. I would condition that on the debug environment
> variable. You might even consider adding __FILE__ and __LINE__
> references then.

No. The only place that is appropriate is G_debug().

Also, that would mean that G_debug() has to be a macro (within
G_debug(), __FILE__ and __LINE__ will refer to G_debug() itself, not
the caller, which isn't much use). But G_debug() is variadic, and
variadic macros aren't ANSI C (gcc provides them as an extension).

--
Glynn Clements <glynn@gclements.plus.com>

Brad Douglas wrote:

> What about adding G_program_name(); to every message, so that
>
> G_message("Hallo, world!");
>
> would produce
>
> g.module: Hallo, world!

Why? This amounts to spam, IMHO. Some module names are 30 characters
wide (I'm looking at you, r.li)! That's nearly half the terminal
length.

I can see it being useful, for the reasons Jachym gives; however:

1. It should be optional (although with all of these environment
variables, I'm starting to worry about platforms which have a 4KiB
limit on the combined size of the command line and the environment).

2. It might be better to put it on a line by itself, and only display
it for the first message or warning, so:

  G_message("Hello,");
  G_message("World!");

would produce e.g.:

  * g.module:
  Hello,
  World!

rather than:

  g.module: Hello,
  g.module: World!

This would be preferable in the cases of modules with long names and
modules which are particularly verbose.

--
Glynn Clements <glynn@gclements.plus.com>