std.experimental.logger formal review round 3
Kevin Lamonte via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 3 04:02:44 PDT 2014
On Thursday, 2 October 2014 at 18:11:26 UTC, Marco Leise wrote:
> How would I typically log an exception?
We could add a Throwable reference in LogEntry and some
overrides. But how exception stack traces appear in the output
(multiple lines, all-on-one line, e.msg only, following the
chain, etc.) should not be firmly set here: we can provide a
reasonable baseline in FileLogger, but other Logger subclasses
will definitely want to do different things.
Another issue is that in practice one will often want to log at
debug an exception they are about to throw (libraries), but log
at error anything they actually catch (applications). Should we
include those use cases too? This skirts very close to the
"policy, not mechanism" line, but might be worth it.
Proposal:
LogEntry {
...
Throwable throwable; /// Optional Throwable
bool caught; /// If true, then throwable was
logged via caught/caughtf
}
void throwing(Throwable t, string msg) {...}
void throwingf(Throwable t, string formatMsg, A... args) {...}
void caught(Throwable t, string msg) {...}
void caughtf(Throwable t, string formatMsg, A... args) {...}
Thoughts?
More information about the Digitalmars-d
mailing list