On Sun, Mar 11, 2012 at 3:28 PM, Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote: > On 3/11/12 4:49 PM, David Nadlinger wrote: >> >> Unfortunately, the discussion has ground to a halt again, so consider >> this a friendly reminder that there is still one day left until the end >> of the review period. >> >> David > > > I thought more about the point made about mixing throwing and logging > levels. I agree that it's awkward to e.g. log to critical without throwing > etc. I personally think in that case you really want the error log, but hey, > point taken. >
I thought about this a lot too and right now I think that if we want to remove asserting from fatal and remove throwing from critical then we should just remove those log levels completely. To me they don't add any additional value. The whole point of having them in the first place was because of their assert and throw semantic. > Here's a suggestion: > > * Don't throw from the critical log and don't abort from the fatal log. > > * Define the logging functions such that logging an exception will log its > toString() and then throw the exception. > This would be great if it made everyone happy but I think it would also confuse developers coming from Java and C#. I think most developer coming from Java and probably C# are used to having: logger.info(e, "format message", ...); log the formatted message and the exception e. Ideally what I would like is: enum Severity { fatal, error, warning, info }; // fatal cannot be disabled // none of the severity levels assert or throw and we have a template: logAndThrow!(FileNotFoundException, Severity.{fatal,error,warning,info})("formatted message", args...); logAndThrow logs the message, and throws a FileNotFoundException object with a message equal to the "formatted message". Unfortunately to implement this in a consistent way I would have to rethink the way the current "façade" is designed/implemented. > * Regarding static import log = std.log, I suggest we keep course. > > Works? > I think there is currently too much disagreement on std.log. I am honestly too busy juggling family, friends, school and work. I am currently leaning towards removing std.log from the review queue and spending some time ironing out the details pointed in this thread. I would like to experiment with some things before making any real suggestions but I would really like to have a logging library that I use throw/assert for me as it would simplify my code. I would like to thank everyone that commented on the design as it was really helpful for me to understand everyone's point of view and expectations. Thanks! Thoughts? -Jose > > Andrei