Re: [Patch] Remove g_print statement



On Sat, 2004-10-16 at 09:41 +0200, Maciej Katafiasz wrote:
> Dnia 15-10-2004, pią o godzinie 18:20 +0200, Christian Glodt napisał:
> > there's a g_print statement in gnome-vfs-mime-info.c.
> > The attached patch removes it.
> > 
> > The g_print statement breaks my app, in which 2 programs
> > communicate through stdout/stdin with a simple string-based
> > protocol. One of the programs uses gnome-vfs, and libgnomevfs
> > printing to stdout interferes with my protocol.
> > 
> > There are some more g_print statements in different vfs modules.
> > It didn't touch these. Don't know if they are actually a problem.
> > Do modules inherit stdout from the process that loads them?
> > I don't remember ever seeing any of the strings that these modules
> > print out. Hm.
> > 
> > Remember, every time you print to stdout from a library,
> > God kills a kitten!
> 
> You can redirect where g_print() outputs to by setting appropriate print
> handler. It may of course be the case that some other variation of
> outputting function (like g_printerr()) should be used in this exact
> case, but generally g_print can be easily dealt with from within apps.

Thanks for the information.

GLib has g_set_print_handler() which I could use to turn off g_print.
But then I wouldn't be able to use g_print from my own program anymore!
That can't be the right way to fix it.

The GLib documentation on g_print says:

"g_print() should not be used from within libraries for debugging
messages, since it may be redirected by applications to special purpose
message windows or even files. Instead, libraries should use g_log(), or
the convenience functions g_message(), g_warning() and g_error()."

So maybe to g_print statement should be changed to a g_message. But I
still fail to see why that particular printout is useful. Isn't it quite
clear that it's left-over debugging spew? It shouldn't even be present
in a stable release, right?

Cheers,

Christian Glodt





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]