Bug 21751 – std.experimental.logger add possibility to pass a throwable to a log
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-23T23:10:32Z
Last change time
2022-07-29T14:49:26Z
Assigned to
No Owner
Creator
etienne
Comments
Comment #0 by etienne — 2021-03-23T23:10:32Z
It would be a nice feature to add the possibility to add a Throwable to logs functions and LogEntry. This would add the possibility to enrich the log with Exception information (like the stack trace), as it’s possible to do in languages like Python or java.
Comment #1 by atila.neves — 2022-07-18T14:08:28Z
Could you please describe, with code, what you would like to see? Thanks.
Comment #2 by etienne — 2022-07-21T08:52:28Z
In java for example I can do
```java
try {
throw new Exception();
}
catch(Exception e) {
log.error("This was unexpected", e);
}
And then in my log, I can have the plain exception object to format it in a particular way. I use this technique to format the log in json and have the stack trace in a separate field of my json log. This allow me to have my log analyzer being able to display the message of the error in the main part and if I expand it, to see the stack trace.
Comment #3 by atila.neves — 2022-07-29T11:43:45Z
I don't understand what's preventing you from doing this now.
Comment #4 by etienne — 2022-07-29T14:49:26Z
Ok, perfect. I close the ticket then. Since i wrote this ticket, I learned how tobuse the loggers.