--
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/4ac068bd-1bf4-4794-8e68-fc69d2b3b2bd%40googlegroups.com.
Loggers in Java already have that facility: it's part of the logging pattern. The logger line itself has no need to incorporate the line number. Note that generating the line number isn't *fast* but the facility is already there.
On Sat, Oct 19, 2019 at 11:08 PM Matei <matei...@gmail.com> wrote:
--Hi,One feature I miss in Java coming from C++ is that log statements cannot automatically pinpoint the source location of the log message. In C++, log statements can be preprocessor macros that use other compiler-specific macros that refer to the file and line number where the log message comes from. In Java on the other hand, I don't know of a way to do this without paying the cost of walking up stack traces. I believe Log4J2 has options related to this, with disclaimers that using them will be slow. As a result, log messages tend to look like:void a() {log.info("a start: ", ...);log.info("a end: ", ...);}void b() {log.info("b start: ", ...);log.info("b end: ", ...);}The boilerplate here are the log prefixes.Since Lombok has the ability to modify existing classes during annotation processing, is there a way Lombok could help with this issue? Assuming log comes e.g. from @Slf4j, could Lombok be used to configure a prefix for log messages, based on things not normally available, such as method name and line number? E.g.:@Slf4j(prefix = "${methodName}:${lineNumber} ")Thanks,Matei
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/4ac068bd-1bf4-4794-8e68-fc69d2b3b2bd%40googlegroups.com.
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/bdbedf16-2b73-4f8e-9dfc-225a95f65bec%40googlegroups.com.
--
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/4ac068bd-1bf4-4794-8e68-fc69d2b3b2bd%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombok+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to project...@googlegroups.com.
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/6a553f2b-6db7-477b-ac24-885884234c82%40googlegroups.com.
but given that the log frameworks _THEMSELVES_ do not, apparently, consider this enough of a big deal to try to at least adapt their API to deal with the crappy situation as best as they can
Thus, having lombok add this is _SOLELY_ a crappy workaround (in that it is a leaky abstraction and makes your code messy and confusing by putting things in places they should not be, and basically messing up a large point of a logging system which is that you configure the format in a single place, and not at the 812430 log statements smeared out across your entire code base).
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/4ac068bd-1bf4-4794-8e68-fc69d2b3b2bd%40googlegroups.com.
--
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/61318c66-b3e8-490c-af0a-0b5e57a07068%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/CAGsWfGgwPg18fJwssW48rxim4T1igzuvJninpXVYM49hnKQyfg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/4ac068bd-1bf4-4794-8e68-fc69d2b3b2bd%40googlegroups.com.
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/61318c66-b3e8-490c-af0a-0b5e57a07068%40googlegroups.com.
--
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...@googlegroups.com.
I'm not excited. Except about the bit where 'log.info(a + b)' turning into a log line that includes the string "a + b", verbatim - now that IS exciting.
The onus of adding a runtime component really sucks though. But, what is the point of having a threadlocal StringBuilder? Isn't the new indy based string concat built into javac itself good enough here? I believe a single expression using + to concat many strings is fine (what's still not fine is something like: String z = ""; for (String a : list) z += a; // nope; you should be using a StringBuilder instead).
But this still means we need to be in the business of making an API. There are already 10 logging APIs, I really don't think we should be in the business of adding another. The lambda unwrap is not needed; given that lombok would already inject an if (logLevelIsEnabled) guard, you can just call f() there. All we're adding here is the method name, and line number, and.. we did not solve the problem where the formatting of these elements relative to the things the log frameworks add for you (logger name which hopefully gives the class name, without which the method name and line number is kinda useless, the level, and a timestamp).
So, cool, but, I kinda need a logger framework builder on board as well at least.
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/379b9fcb-48af-4e68-998e-02c6bfbb8715%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/379b9fcb-48af-4e68-998e-02c6bfbb8715%40googlegroups.com.
FTR- If the String-s are not reliable today, one would need a ThreadLocal pool of StringBuilder-s, to allow for the exceptional but alas possible case of recursion occuring during the processing of a log statement: log.info(f()), with the very same statement being reached again while f() is running.
The Lombok solution would need at minimum a new configuration option (also settable from lombok.config) e.g. @Slf4j(enableLombokFormatting = true)
Beyond that, it might be useful to add the option to name the arguments by index instead of copying the string, e.g.
@Slf4j(useArgumentIndexAsName = true)
log.info(a, b+c) => "[0]=5, [1]=7"
This is meant as a fallback solution when the expressions themselves are too cumbersome to have in the log line.
Or should we just let you write your logging statements as you had them, and attempt to 'mess' with them in place, and inject an if-based guarding statement to skip it entirely if the log level is not enabled?
Just.. use the public static final `log` field in class `lombok.LombokLogger` and we'll take care of everything else, based on guidance in the lombok.config file about what framework to use.
I prefer generating an error that explains what to do if you did not configure this; I prefer this over picking some default logging framework to use if you don't explicitly pick one in lombok.config and also over having 1 `lombok.Slf4jLombokLogger` named class for each and every framework we support.
I don't think it is a good idea to suggest to the user that you should/can use static imports to end up with a java statement: `info(a + b)`. That's too obscure to my tastes; it is no longer obvious that line tries to log that expression (including the actual string "a + b") at loglevel INFO. Put `log.` in front of it and I think we're good.
IF we go for full API replace, how do we cater to exotic logging features, for example, flogger's `atMostEvery` and `every`?
Given that the threadlocal trick requires a _LIST_ of stringbuilders or logging calls cannot themselves execute code that would also produce logging calls without messing everything up,
But, if the performance of straight string concat just will not do, well, if people like Pascal wouldn't use this feature, why are we bothering to build it?
--
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/6068c3fe-20b9-449c-85d4-a6057352d0ce%40googlegroups.com.
>> To unsubscribe from this group and stop receiving emails from it, send an email to project...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/6068c3fe-20b9-449c-85d4-a6057352d0ce%40googlegroups.com.
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/74a39fbc-01b1-42e4-a3f7-fc20962c4746%40googlegroups.com.
>> To unsubscribe from this group and stop receiving emails from it, send an email to project-lombok+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/6068c3fe-20b9-449c-85d4-a6057352d0ce%40googlegroups.com.
>
> --
> 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-lombok+unsubscribe@googlegroups.com.
We could have a @LogGeneratedMethodEntry annotation that applies to everything lombok generated, but now you can't be selective about which method(s) you want them on.
>> 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/6068c3fe-20b9-449c-85d4-a6057352d0ce%40googlegroups.com.
>
> --
> 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/CAGsWfGhS0TeKZwUQxWjYuufK0DyoQ3Vd8gEMfpa-CLWGNfCPwA%40mail.gmail.com.
--
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/0c8df1ba-c957-4d1f-af2f-02f5d4c767dd%40googlegroups.com.