Line number generation

24 views
Skip to first unread message

Roger Glover

unread,
Jul 2, 2024, 12:04:15 PMJul 2
to Project Lombok
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?

Mat Jaggard

unread,
Jul 2, 2024, 12:15:44 PMJul 2
to project-lombok
Hi,
Welcome to the group. I'm afraid your suggestion has been discussed at length several times with no satisfactory conclusion except that it would be almost impossible to do and if it was possible it should be solved by the logging frameworks.

Have a look for "Could Lombok help with log context?" or something about C macros in the history of this group.

Many thanks,
Mat.

--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/84ce4476-8299-433d-a4a0-ba4922a5890cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages