derbylock / missing-link

Automatically exported from code.google.com/p/missing-link
0 stars 0 forks source link

Make the task less verbose by default #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I find a little strange that there's so much things printed by default. I think 
that in the nominal case, the useful information is the url and the response 
code. If something doesn't behave correctly, then the end user could turn ant 
into the verbose mode, and he can gets every info about its http request and 
response.

See attached a suggested patch.

Original issue reported on code.google.com by nicolas....@gmail.com on 6 May 2011 at 9:00

Attachments:

GoogleCodeExporter commented 8 years ago
+1, I frequently end up running Ant in -quiet because of Missing Link output. 
The output is useful when I explicitly ask for it (e.g. a debugging session), 
otherwise it tends to end up as noise.

Original comment by stephens...@googlemail.com on 9 Aug 2011 at 1:39

GoogleCodeExporter commented 8 years ago

Original comment by alex.she...@gmail.com on 18 Aug 2011 at 1:16

GoogleCodeExporter commented 8 years ago
Made the debugging utilize built-in ant logging levels for brevity.  By 
default, the INFO level messages will now print as such:

     [http] HTTP Request
     [http] ********************
     [http] URL:                http://www.google.com/
     [http] Method:             GET
     [http]
     [http] HTTP Response
     [http] ********************
     [http] Status:             200

While run with -verbose, will look like:

     [http] ********************
     [http] HTTP Request
     [http] ********************
     [http] URL:                http://www.google.com/
     [http] Method:             GET
     [http] Headers:            no
     [http] Query Parameters:   no
     [http] Entity:             no
     [http]
     [http] ********************
     [http] HTTP Response
     [http] ********************
     [http] Status:             200
     [http] Headers:            yes
     [http]     HTTP/1.1 200 OK
     [http]     Transfer-Encoding: chunked
     [http]     Date: Thu, 18 Aug 2011 13:53:50 GMT
     [http]     X-XSS-Protection: 1; mode=block
     [http]     Expires: -1
     [http]     Set-Cookie: NID=50=r20TP23DAHGUgQgoUp8R8Nx-7CaSKw0bZbpcm76Thjuk3h3XHyuD2XhpuMrl0bAKNwOLS3I1rRzIRzzxB1NfUGPjFFHulwEhNPMkEhUS2z8gDTJ9-93mYIufMZ6fT-OU; expires=Fri, 17-Feb-2012 13:53:50 GMT; path=/; domain=.google.com; HttpOnly

     [http]     Set-Cookie: PREF=ID=c1b6da0aafda2bee:FF=0:TM=1313675630:LM=1313675630:S=5_g2PzPikR-aBqtd; expires=Sat, 17-Aug-2013 13:53:50 GMT; path=/; domain=.google.com
     [http]     Content-Type: text/html; charset=ISO-8859-1
     [http]     Server: gws
     [http]     Cache-Control: private, max-age=0
     [http] Entity:             yes

Original comment by alex.she...@gmail.com on 18 Aug 2011 at 1:56

GoogleCodeExporter commented 8 years ago
I didn't utilize the patch on this Issue for a few reasons.  First, it has 
conflicts caused by other patches and updates, second is I didn't particularly 
like the formatting and levels chosen for particular parts of the output.  

To me the submitted patch didn't clearly distinguish between req/resp areas 
enough, so my changes might be slightly more verbose then the patch, but far 
quieter then the previous output.  See the previous comment for the differences 
now.

Changes will be available in the next release (1.1.3)

Original comment by alex.she...@gmail.com on 18 Aug 2011 at 2:00

GoogleCodeExporter commented 8 years ago
If I may, I still find the output very verbose: 8 lines for 3 pieces of 
information.
For instance the _verbose_ mode of the "copy" is printing things like:
"Copying /tmp/myfile to /tmp/myotherfile"

With logs such as the http task has, it would be:
Source File
********************
source : /tmp/myfile

Destination File
********************
dest : /tmp/myotherfile

overkill I think.
But it's just my opinion.

Original comment by nicolas....@gmail.com on 18 Aug 2011 at 2:12

GoogleCodeExporter commented 8 years ago
Maybe we can do an option on the task to make it quieter.  

I feel like your comparison to the copy method is unfair, the information 
encompassing a file copy can clearly be wrapped up into a few words

To me, the basic information that I would always want to see about an HTTP 
request, even in a "quiet" mode, would be the request type, URL, response 
status.

My formatting is slightly verbose, because I looked for a way to try and 
introspect the and "Project" at run time to determine the current logging 
threshold, but, alas it appears Ant does not expose this (unless I am missing 
something).  The reason I wanted to do this, was so that I could change the 
output for the log lines that come in both INFO/VERBOSE if VERBOSE was/wasn't 
set.  But since I can't find a way to do this, I went to the lowest common 
denominator approach to have some consistent log messages

Original comment by alex.she...@gmail.com on 18 Aug 2011 at 3:54

GoogleCodeExporter commented 8 years ago
> Maybe we can do an option on the task to make it quieter.  

That would be nice then.

> I feel like your comparison to the copy method is unfair, the information 
encompassing a file copy can clearly be wrapped up into a few words

I have to admit it is quite unfair, but I think two lines are very sufficient 
for the 3 pieces of information we want.

>To me, the basic information that I would always want to see about an HTTP 
request, even in a "quiet" mode, would be the request type, URL, response 
status.

I agree. Hence my suggested patched.

>My formatting is slightly verbose, because I looked for a way to try and 
introspect the and "Project" at run time to determine the current logging 
threshold, but, alas it appears Ant does not expose this (unless I am missing 
something).  The reason I wanted to do this, was so that I could change the 
output for the log lines that come in both INFO/VERBOSE if VERBOSE was/wasn't 
set.  But since I can't find a way to do this, I went to the lowest common 
denominator approach to have some consistent log messages

Indeed you can't. But are these ASCII headers really needed ?

I don't want to appear stubborn of this nitpicking formatting issues on these 
nearly indispensable http ant tasks, but here is what I suggested with my patch:
In INFO:
     [http] GET http://www.google.com/
     [http] Response: 200
In VERBOSE:
     [http] GET http://www.google.com/
     [http]     URL:                http://www.google.com/
     [http]     Method:             GET
     [http]     Headers:            no
     [http]     Query Parameters:   no
     [http]     Entity:             no
     [http] Response: 200
     [http]     Headers:            yes
     [http]         HTTP/1.1 200 OK
     [http]         Transfer-Encoding: chunked
     [http]         Date: Thu, 18 Aug 2011 13:53:50 GMT
     [http]         X-XSS-Protection: 1; mode=block

not perfect, url and method is repeated for the request and should probably be 
removed from the verbose mode, but I think it is nicely readable thanks to the 
indentation.

Original comment by nicolas....@gmail.com on 18 Aug 2011 at 4:11

GoogleCodeExporter commented 8 years ago
Nicolas,

It just hit me.. there is no spoon.  No one said we had to play be the rules, 
so I stole a play from the Spring playbook (picked this up when digging into 
how Spring can do Dependency Injection into private/protected members with no 
getters/setters)

  protected int getLogLevel() {
    try {
      for (final Object listener : getProject().getBuildListeners()) {
        if (DefaultLogger.class.equals(listener.getClass())) {
          final Field msgOutputLevel = listener.getClass().getDeclaredField("msgOutputLevel");
          msgOutputLevel.setAccessible(true); // there is no spoon
          final int logLevel = msgOutputLevel.getInt(listener);
          return logLevel;
        }
      }
    } catch (final Exception e) {
      throw new BuildException(e);
    }
    return Project.MSG_INFO;
  }

This allows me to modify the output depending on the log level and will make me 
a happy camper, so I will shorten up the output for the default level for 1.1.4

Original comment by alex.she...@gmail.com on 19 Aug 2011 at 11:44

GoogleCodeExporter commented 8 years ago
Better?

C:\work_ml\ant-http\trunk\dist\ml-ant-http-1.1.3>ant -f build-sample.xml
Buildfile: C:\work_ml\ant-http\trunk\dist\ml-ant-http-1.1.3\build-sample.xml

http-get:
     [http] HTTP GET http://www.google.com/
     [http] Response Status: 200

BUILD SUCCESSFUL
Total time: 0 seconds

C:\work_ml\ant-http\trunk\dist\ml-ant-http-1.1.3>ant -f build-sample.xml 
-verbose
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Buildfile: C:\work_ml\ant-http\trunk\dist\ml-ant-http-1.1.3\build-sample.xml

http-get:
     [http] ********************
     [http] HTTP Request
     [http] ********************
     [http] URL:                http://www.google.com/
     [http] Method:             GET
     [http] Headers:            no
     [http] Query Parameters:   no
     [http] Entity:             no
     [http]
     [http] ********************
     [http] HTTP Response
     [http] ********************
     [http] Status:             200
     [http] Headers:            yes
     [http]     HTTP/1.1 200 OK
     [http]     Transfer-Encoding: chunked
     [http]     Date: Fri, 19 Aug 2011 12:01:50 GMT
     [http]     X-XSS-Protection: 1; mode=block
     [http]     Expires: -1
     [http]     Set-Cookie: NID=50=Sb3fULSoiZva6UBGOanOTrIU5R8dhBHYpIZ0a94MD1PUhGP1kLatbzsu8Df2qtj6u_qwekPTsiW3xGFcnZuqhTEFE_o6mqvxuuX0JP4x9sNJJBHZEl0L-O_HDx-JKguU; expires=Sat, 18-Feb-2012 12:01:50 GMT; path=/; domain=.google.com; HttpOnly
     [http]     Set-Cookie: PREF=ID=ef7ffbc95c291570:FF=0:TM=1313755310:LM=1313755310:S=q86ysWb9dJ23UM2_; expires=Sun, 18-Aug-2013 12:01:50 GMT; path=/; domain=.google.com
     [http]     Content-Type: text/html; charset=ISO-8859-1
     [http]     Server: gws
     [http]     Cache-Control: private, max-age=0
     [http] Entity:             yes

BUILD SUCCESSFUL
Total time: 0 seconds

Original comment by alex.she...@gmail.com on 19 Aug 2011 at 12:08

GoogleCodeExporter commented 8 years ago
seems nice !

About the implementation hack, I would suggest you to be defensive regarding 
the success of getting the error log. Ant developers are very attentive to 
backward compatibility, but here a private field is used, so it is possible it 
changes in the future. Then throwing a BuildException may be rude for such 
logging problematic. A warn log should be sufficient.

Original comment by nicolas....@gmail.com on 19 Aug 2011 at 12:24

GoogleCodeExporter commented 8 years ago
Excellent point, I've changed it to be more defensive

Original comment by alex.she...@gmail.com on 19 Aug 2011 at 12:42

GoogleCodeExporter commented 8 years ago

Original comment by alex.she...@gmail.com on 19 Aug 2011 at 12:51