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

Re: [Nbd] About error management



On Fri, Dec 28, 2012 at 05:19:08PM +0000, Alex Bligh wrote:
> 
> I'm not a huge fan of the the GError stuff. I admit most of that is
> ignorance, but my main criterion for a daemon is that it can send
> errors to the syslog (if running as a daemon) or stderr (in debug
> mode) via a CLI switch. Some form of 'debug level' passing is also
> useful.
> 

If we are talking about g_message(), g_warning() etc., then I'm not a
huge fan either. syslog() and fprintf() should probably suffice.

But libglib's error reporting system is essentially about GError,
which makes it quite easy to propagate/convey error codes upwards and
even from one error domain to another. I've written a custom error
propagation functionality for a couple of smaller projects to avoid
adding otherwise unnecessary dependency on libglib, but because NBD
needs libglib also for other things, using GError to convey errors
between functions seems the easiest way forward in my opinion.

Then it's another thing how we should print those errors and on what
medium. As I said, syslog() and fprintf() would be my choices. We
could even drop fprintf() completely and always use syslog(). We'd
just pass LOG_PERROR to openlog() in case we have stderr (debug, and
before daemonizing).

(And then there's always the possibility to use fopencookie() to
redirect stderr to syslog.)

-- 
Tuomas



Reply to: