I would like to include source line numbers in my Java logging messages. However, the best current solution (generate a bogus exception and parse the stack trace) seems unnecessarily heavy-handed.
It occurs to me that it would be great if there were some sort of macro-like way to capture the line number at or before compile time and insert it into the logging message. Java is no help and I really don't want to write my own annotation processing library for this purpose.
Sounds (to me) like a job for Project Lombok!
- Maybe as an option to the logging annotations?
- Maybe as an annotation on it's own to make the line number capture even more general purpose?
Of course. like most Lombok users, I don't even know if such a thing is possible or feasible. What do you experts think?