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. It is much easier to just go getLogger().debug( .... ) Far more user/developer friendly. 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(...); -- Cheers, Pete ------------------------------------------------------- "I would like to take you seriously but to do so would affront your intelligence" -William F. Buckley, JR ------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>