Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1667

Re: Terse code sought

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.help
Subject Re: Terse code sought
Date Sun, 25 Mar 2012 18:23:13 -0700
Organization A noiseless patient Spider
Lines 44
Message-ID <jkoge2$3ch$1@dont-email.me> (permalink)
References <8f7sm7hd60f72vlc47ul8793gvgv9j1a89@4ax.com> <EXrbr.7472$Ce4.1357@newsfe21.iad> <KYwbr.11514$532.1969@newsfe14.iad>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 26 Mar 2012 01:23:15 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="QNqT5u6Ryx/DB+LpnoCWdQ"; logging-data="3473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tPMcK5KChg/+qEVg5Qfyw5E1MTSOCXdo="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120312 Thunderbird/11.0
In-Reply-To <KYwbr.11514$532.1969@newsfe14.iad>
Cancel-Lock sha1:CiU+WSgMaiehHJwtIw4hE1bNfe4=
Xref csiph.com comp.lang.java.help:1667

Show key headers only | View raw


>> On 12-03-24 04:32 PM, Roedy Green wrote:
>>> Consider the following code, typical of the sort of thing I pepper my
>>> code with when debugging.
>>>
>>> out.println( "maxBraceNesting:" + maxBraceNesting + "
>>> maxBracketNesting:" + maxBracketNesting + " maxParenthesisNesting:" +
>>> maxParenthesisNesting );

> On 3/24/12 3:32 PM, Arved Sandstrom wrote:
>> System.out.println("${var} = " + ${var});

On 3/24/2012 9:14 PM, Daniel Pitts wrote:
> I'll point out that IntelliJ has a template for this by default. "soutv"


I just want to point out these each of these is somewhat of a rube 
solution.  A better approach is to use the logger method with parameters:

<http://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html#log%28java.util.logging.Level,%20java.lang.String,%20java.lang.Object[]%29>

All of the other ideas mentioned above call the toString() method of 
every object concerned, and also use a StringBuilder to construct a new 
string.  Both of these can have considerable overhead.

Whereas the log method with parameters doesn't invoke any of these if 
the log level test does not pass, thus being much "lighter weight" at 
run time.

The parameter substitution is "{n}" where n is a number encoded as a 
string >= 0.  Example:

   logger.log( Level.FINEST, "myVar = {0}, otherVar = {1}", myVar,
                otherVar );

Read the bit here (at the TOP of the page) where it talks about "msg 
argument".

<http://docs.oracle.com/javase/7/docs/api/index.html?java/util/logging/Logger.html>

Back on topic: no I don't know of a macro that auto generates those for 
you. :)


Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Terse code sought Roedy Green <see_website@mindprod.com.invalid> - 2012-03-24 12:32 -0700
  Re: Terse code sought Lew <noone@lewscanon.com> - 2012-03-24 14:50 -0700
  Re: Terse code sought Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-24 19:32 -0300
    Re: Terse code sought Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-24 21:14 -0700
      Re: Terse code sought markspace <-@.> - 2012-03-25 18:23 -0700
        Re: Terse code sought Roedy Green <see_website@mindprod.com.invalid> - 2012-03-25 20:28 -0700
          Re: Terse code sought markspace <-@.> - 2012-03-26 07:59 -0700
        Re: Terse code sought Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-26 07:04 -0300
          Re: Terse code sought markspace <-@.> - 2012-03-26 08:02 -0700
            Re: Terse code sought Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-26 09:57 -0700
            Re: Terse code sought Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-26 20:32 -0300

csiph-web