Review of Jose Armando Garcia Sancio's std.log
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Mar 6 16:50:22 PST 2012
On Tue, Mar 06, 2012 at 07:25:23PM -0500, Jonathan M Davis wrote:
> On Tuesday, March 06, 2012 13:08:42 Brad Roberts wrote:
[...]
> > I still believe pretty strongly that the logger must not affect
> > application flow, ie, not throw or exit the app. From the feed back,
> > I am not alone in thinking that. I don't believe that "well, don't
> > use those log levels" is a workaround if for no other reason that
> > there will be libraries that contain them and that becomes a "dont
> > use those libraries either" response.
>
> Agreed. The logging functions should _not_ throw.
[...]
+1. Logging functions are for ... logging? Not for managing errors.
Leave it up to the user to define something like the following, if
they're so inclined:
void logAndAbort(T...)(string fmt, T args) {
critical(fmt.format(args));
throw new CriticalError(...);
}
One shouldn't have to write a try/catch block just so one can log a
critical message and continue doing whatever it is needs to be done.
(For example, you might want to log a critical condition immediately to
ensure the sysadmin sees the message, before proceeding to attempt
self-recovery that *may* fail and crash the system, and thereby lose the
ability to log a message.) Let the user decide whether or not to throw.
T
--
Why have vacation when you can work?? -- EC
More information about the Digitalmars-d
mailing list