[GRASS5] stdout and stderr

Radim Blazek blazek at itc.it
Tue Oct 19 10:47:50 EDT 2004


On Sunday 17 October 2004 15:04, Paul Kelly wrote:
> Hello developers
> I was just wondering about the appropriateness of writing different types
> of module output to stderr or stdout, as I notice there has been some
> activity in 5.7 in this area recently. I am wondering if perhaps I have
> been wrong about how this should be used before:
>
> When writing new code and fixing bugs I have tended to ensure that only
> output which is the actual result of a GIS processing operation that needs
> to be displayed to the user (rather than written to a file in the GRASS
> database) should be written to stdout. All other errors, warnings,
> informative progress messages and copyright notices etc. are written to
> stderr.

I am not sure. If info (no error/progress) is printed to stdout
it cannot be separated from data.

> I suppose that for modules that only write output to another file in the
> GIS database, having information messages printed to stdout wouldn't
> result in mixing up, but still I was under the (possibly mistaken)
> impression that writing to stderr ensured the messages would always appear
> where the user could see them and act on them, regardless of where stdout
> was appearing (e.g. in a future GUI perhaps the stdout would be placed in
> a pretty 'results' window to be stored while stderr could be kept out of
> the way).

My suggestion for discussion:
data     -> stdout
messages -> stderr

and it should be consisten for all modules even if data are not printed.
Only stderr could be translated.

Examples for data: 
- v.out.ascii without output
- v.category option=print
- v.to.db -p
- g.region -g

Messages:
- g.region -p
- r.info

For GUI, I suggest (as posted previously) some standard format,
i.e. add more prefixes like WARNING and ERROR, e.g. PERCENT.

We should also add the G_message, maybe with type ?
void G_message ( int type, const char *msg );

Radim













More information about the grass-dev mailing list