[bind10-dev] logging and exception
Jelte Jansen
jelte at isc.org
Wed Jun 22 19:49:15 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>On 06/22/2011 08:56 PM, JINMEI Tatuya / 神明達哉 wrote:
> What should we do with this?
> 1. Ensure LOG_xxx never throws by not doing dynamic memory allocation
> or not using throwing new, etc. I'm afraid this is too costly and
> makes the underlying implementation more complicated.
> 2. Similar to #1, but simply catch any exception from the logger and
> ignore it:
> #define LOG_DEBUG(LOGGER, LEVEL, MESSAGE) \
> if (!(LOGGER).isDebugEnabled((LEVEL))) { \
> } else { \
> try { \
> (LOGGER).debug((LEVEL), (MESSAGE)); } \
> } catch (...) {}
> I don't like this either, but in this context it may be a least
> evil and acceptable option.
> 3. Do not make logs in the context where an exception isn't supposed
> to be thrown. I don't think this is realistic or too restrictive.
> 4. Pretend the problem doesn't exist and ignore it because the
> exception in question would normally only happen in rare cases such
> as memory shortage. This may be acceptable as a compromise, but
> I'd rather prefer #2 than this one.
>
> Or is there a better solution?
>
assuming we're thinking of something similar for #1, it would certainly be more
complicated, but I think it could actually be more efficient. However, I would
also consider that premature optimization (when you hold option #2 next to it),
and as long as we only use the macros, we do have a nice abstraction that can be
changed internally.
So for now I would agree that #2 would be the best approach. Even better if we
can add one exception-free way in the catch to somehow report that something is
extremely wrong.
Jelte
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4CRzsACgkQ4nZCKsdOncVtYgCfVqX0DEUll3vEZYFSYxg/YI4y
37UAoKUGg3aYmJsI/ZmZdFz36s1QNYGA
=w8Xk
-----END PGP SIGNATURE-----
More information about the bind10-dev
mailing list