[GRASS-dev] Using grass.message in Python: Why does G_message() print to stderr and not stdout?
Markus Neteler
neteler at osgeo.org
Sun Sep 9 07:46:34 PDT 2018
On Sun, Sep 9, 2018 at 4:23 PM Markus Metz
<markus.metz.giswork at gmail.com> wrote:
> On Sun, Sep 9, 2018 at 3:47 PM Markus Neteler <neteler at osgeo.org> wrote:
> >
> > Hi,
> >
> > Why does G_message() print to stderr and not stdout?
> > https://trac.osgeo.org/grass/browser/grass/trunk/lib/gis/error.c#L84
>
> Messages, warnings and errors are not output. Consider g.region -g, r.info -g, r.univar -g or any module that produces an output file with default output=- meaning stdout. You don't want any messages in the output if the output is to be automatically parsed later on.
OK, I see.
So, for output like "Step X: processing ...:" I need to use print()?
My preferred way would be grass.debug() because then I would later
switch these message to level 1 in order to "hide" them. Yet, I think
that they disappear...
I'd also like to see a way to print through the parser, i.e. a
functionality similiar to "sh -x shellscript" which prints every step.
Is that possible?
markusN
More information about the grass-dev
mailing list