[GRASS5] -q flag for r.cats and other commands

Hi,
I'm using grass via some java servlets and recently found out that
any G_percent() messages and others are sent to the stderr
(thanks to Glyn Clements).

While I have been able to program around this,
It makes my use of stderr a bit messy. I trap
all stderr messages and display them in a error log
(in RED). However now I have to modify this, and
try and determine which of them is a activity message
and which is a real GRASS command error or warning message.

Has there been any discussion on a standard syntax
for error and warning message (prefixed with ERROR
or WARNING, maybe) or on this whole topic.

I would love to have the -q flag on all commands
but I don't know how much support there is for
that.

John Preston

John A. Preston wrote:

I'm using grass via some java servlets and recently found out that
any G_percent() messages and others are sent to the stderr
(thanks to Glyn Clements).

While I have been able to program around this,
It makes my use of stderr a bit messy. I trap
all stderr messages and display them in a error log
(in RED). However now I have to modify this, and
try and determine which of them is a activity message
and which is a real GRASS command error or warning message.

Has there been any discussion on a standard syntax
for error and warning message (prefixed with ERROR
or WARNING, maybe) or on this whole topic.

There has been some discussion. I've suggested that error, warning and
status messages could be handled more consistently, and I'm fairly
sure that nobody actually objected.

Actually getting it implemented is another matter. However, one of the
main issues for 5.1/6.0 is a general clean-up of the code, and
handling of messages should be part of that.

Having said that, any error message generated by G_fatal_error() will
begin with "ERROR:", and any warning message generated by G_warning()
will begin with "WARNING:"[1].

However, some programs simply print messages to stderr (or even
stdout). Markus recently cleaned up the error handling in a number of
modules, but I don't expect that he will have fixed all of them.

[1] By default. The code in question has recently been
internationalised, so the strings could change depending upon locale
settings. However, the internationalisation is disabled unless you use
the --with-nls switch when configuring.

I would love to have the -q flag on all commands
but I don't know how much support there is for
that.

The idea of "common" options and flags has also been discussed in the
context of enhancing the GRASS parser but, again, no firm decisions
have been made.

--
Glynn Clements <glynn.clements@virgin.net>

Having said that, any error message generated by G_fatal_error() will
begin with "ERROR:", and any warning message generated by G_warning()
will begin with "WARNING:"[1].

That's what I need for now.

However, some programs simply print messages to stderr (or even
stdout).

The ones to stdout I print in the log as program messages while
the ones to stderr I'll simply ignore.

Thanks.

John Preston

On Thursday 18 July 2002 04:06 pm, John A. Preston wrote:

> Having said that, any error message generated by G_fatal_error() will
> begin with "ERROR:", and any warning message generated by G_warning()
> will begin with "WARNING:"[1].

That's what I need for now.

Remember that long messages are split to more rows:
----------------------------------------------------------------------
WARNING: A map which is not in the current mapset cannot be opened for
         update.
----------------------------------------------------------------------

You can change the way messages are printed in libes/gis/error.c

Radim

On Thu, 18 Jul 2002 16:30:25 +0200
Radim Blazek <blazek@itc.it> wrote:

Remember that long messages are split to more rows:
----------------------------------------------------------------------
WARNING: A map which is not in the current mapset cannot be opened for
         update.
----------------------------------------------------------------------

Yes. I capture all of the stderr message.

You can change the way messages are printed in libes/gis/error.c

I don't want to change how grass is. I want to add onto grass so
I prefer to adapt my code to work with grass.

Thanks.

John

On Wed, Jul 17, 2002 at 11:57:38PM +0100, Glynn Clements wrote:

John A. Preston wrote:

> I'm using grass via some java servlets and recently found out that
> any G_percent() messages and others are sent to the stderr
> (thanks to Glyn Clements).
>
> While I have been able to program around this,
> It makes my use of stderr a bit messy. I trap
> all stderr messages and display them in a error log
> (in RED). However now I have to modify this, and
> try and determine which of them is a activity message
> and which is a real GRASS command error or warning message.
>
> Has there been any discussion on a standard syntax
> for error and warning message (prefixed with ERROR
> or WARNING, maybe) or on this whole topic.

[...]

However, some programs simply print messages to stderr (or even
stdout). Markus recently cleaned up the error handling in a number of
modules, but I don't expect that he will have fixed all of them.

[...]

find . -type f -name '*.c' -exec grep printf {} \; |grep ERROR | wc -l
    442

quite a few entries...

Markus