Peter Donald wrote: > > On Sat, 27 Oct 2001 23:48, Stefano Mazzocchi wrote: > > > > IMO, the Avalon LogKit should force (or at least *highly* incouradge) > > > > people to use this approach. > > > > > > (1) is useful in the 1.2 JVMs because they don't optimize aswell as 1.3+. > > > (2) will still cause 5-8 operations/comparisons before opting out in > > > jdk1.2 but in later JVMs this will be optimized down to one comparison > > > and a jump. > > > > > > I am not sure how it can be "forced" other than via recomendation ;) > > > > Good point. > > > > A possible solution is to require the logging channel instance to be > > obtained only after checking if available... we can use some polymorphic > > code like > > > > LogChannel debug = (LogChannel) getLogger().debug(); > > if (debug != null) debug.log(...); > > > > which is sort of inverted over the normal use but rightly forces the > > logging code to obtain a reference to the log channel *before* doing > > anything (pain NPE all over the place!). > > > > Not sure I like this much, but it's a way to do it. > > > > What do you think? > > Too painful to use.
Yes, I share your perception. > It is much easier to just go > > getLogger().debug( .... ) > > Far more user/developer friendly. Totally. Ah, as a side note: why are you guys always suggesting doing getLogger()? couldn't we make the logger variable of AbstractLoggable protected so that extending classes already have access to it and avoid making method calls to retrieve it? it's both easier and faster, but maybe you guys thought of something I'm forgetting, thus my questions. > In 80% of cases performance is a non-issue > and thus the painful API would drive people away from using it. For those 20% > of cases where performance is still an issue I cant see much difference in > above and following. Actually I would still say the following is better ;) > > if( getLogger().isDebugEnabled() ) getLogger().debug(...); Oh, I agree. I was just proposing a way of forcing people, but you're right: suggesting, in this case, is easier. One thing only: make sure the logkit documentation lists best practices along with their reasons. -- Stefano Mazzocchi One must still have chaos in oneself to be able to give birth to a dancing star. <[EMAIL PROTECTED]> Friedrich Nietzsche -------------------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>