We call it a LOGGER where I come from....
A logger is a static final field, i.e. a constant IIUIC (I can't find
any definition now). According to
http://www.oracle.com/technetwork/java/codeconventions-135099.html#367
it should be all uppercase. However, I don't think doing it is of any
use for private constants as there are not very important and may easily
turn to variables.
> Definitely not the standard style. It also makes log statements stand
> out like a sore thumb, while I'd say it would make more sense that log
> statements stand out no more than, and preferably less than, the rest of
> the code.
Agreed. I'd be happy if there was a highlighting for eclipse allowing
making logging statements (and asserts) gray (in Emacs it was easy to do
it myself).
> We might at some point give you the ability to change the name of the
> 'log' variable. But there are other names (such as the class / name of
> the logger to log to), so we didn't want to give up the ability to make
> an experience-based call on what we spend our parameters for @Log on
> right from the outset.
I don't think changing the name of the variable on a per-class basis is
worth it. I strongly prefer "logger" to "log", but not enough to declare
it again and again. If I only could do it once globally (or at least
once per package)....
I sort of agree, but in Emacs I was using a pattern marking
if(x) {...}
in a very bad color as opposed to
if (x) {...}
which can't be done using any AST. In theory, this is unnecessary, since
Eclipse support source code formatting, in practice, this formatting is
too terrible to be switched on.
> Instead, you'd define that any statement which
> is an execution of a method call to a method on a configured or
> hardcoded list is to be rendered in a certain style. However, this
> requires resolution and to date I have yet to find an IDE that uses a
> resolution strategy compatible with applying it many times a second.
I'm quite sure it's doable, since the resolved method surely does not
change many times a second, actually it hardly ever changes.
> I agree (mostly) with the IDE side here, but when the upshot is that you
> can mask out log statements in emacs but eclipse isn't there yet,
> something's a bit off. But that's a discussion for another day.
Yes, the IDE principle is clean and beautiful, it just doesn't work.
> We won't add externally configurable* stuff to lombok because it would
> mean the mere act of a moving a source file around may result in code
> that doesn't compile, or, worse, compiles to something else.
What about
@Lombok(maaartin.MyLombokConfig) @Log @Getter
class MyClass {...}
package maaartin;
public class MyLombokConfig implements LombokConfig {
public LoggerKind loggerType {return LoggerKind.SLF4J;}
public String loggerName {return "logger";}
public String getterName(String fieldName) {...}
}
? Is this an external or internal configuration to you?
I don't know if this is doable, but IMHO it's explicit enough - there's
an explicit pointer to the whole configuration in each file. Instead of
repeating the parameters for each source file and each lombok feature
again and again, you could define them once only.
> When jigsaw
> is released in JDK8 we might revisit this (because the module gives us a
> decent base for storing these settings, though code is usually treated
> as far more granular than the module level still, so no promises).
This would be nice, but I don't care much what happens in 20 years. :D
> The
> gain of catering to personal tastes does not get even remotely close to
> the loss of granularity and readability of code due to basically being
> forced to review the settings of lombok (and, hence, knowing what lombok
> is in the first place) before you figure out why that code you're
> looking at isn't compiling or doing the right thing on your machine.
Sure, the personal taste is not important enough. But there are other
things like some libraries having some requirements to be met (e.g.,
requiring always using "get" as a prefix). And with lombok growing there
will be more and more things to be configured.
> Lombok itself,as it exists now, doesn't suffer from this problem because
> the notion of "I'm missing a dependency" is already commonly known
> amongst java programmers, and all lombok features have a clearly marked
> dependency on some type that's in the lombok package. Lombok does suffer
> from the problem that the programmer may not understand that *ANY*
> library could possibly do what lombok does, but that's an obviously
> intractable problem which we solved by being the first hit on google for
> for example "lombok java". Can't win em all :)
Sure, you're sort of creating a new language and you can't do more in
this respect than you're doing. Maybe except for getting the TLD
"lombok", so the package name would conform. However, Sun didn't do it
either. :D
> *) vs. internally configurable, which is what you're doing when you
> write something like @Getter(AccessLevel.PROTECTED).
PS: Some time ago I reported an error in
http://projectlombok.org/features/GetterLazy.html
and it's still there (maybe spam folder?). It doesn't compile because of
mixing int[] and double[].
To be honest I don't know where LOGGER came from. I'm sure I'm somehow responsible but it doesn't make a big difference now.
While I'd prefer logger to log it certainly isn't a deal breaker.
Van: nik...@gmail.com [mailto:project...@googlegroups.com] Namens Nikolas Everett
Verzonden: 17 December 2010 13:10
Aan: project...@googlegroups.com
Onderwerp: Re: [project lombok] @Log should generate a private static field "logger" rather than "log"
Groups group for http://projectlombok.org/
--
Sure, but this single annotation can be used to configure everything, so
you can't lose. If there's nothing to configure, you don't need it. If
there's one thing to configure, you break even. With more you win.
It allows configuring things like the logger variable name, which (as
you wrote later in this thread) are otherwise not worth it. It could be
used to specify the kind of logger in case you decide "move away from
the @Log annotation entirely" (as you wrote today). It could be used to
determine the formatting of @ToString, which is something you don't want
to repeat in each class. It would also allow the user-specified
annotation rewriting discussed in
http://groups.google.com/group/project-lombok/browse_thread/thread/a8c01b2226c081cb
> We could allow moving it to the package-info.java
> file or even the JDK8 module-info.java file, but that increases the
> portability issues).
Sure, there are always such problems with everything not fully explicit.
I think, I could live with it.
> Interesting stuff, certainly. Fortunately (?) we can table it for now;
> we have more pressing fish to fry, such as getting 0.10.0 out the door.
> We haven't forgotten about that bug report.
;)