Colourizing console output

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Colourizing console output

Russel Winder
We had a short discussion about console output colouring and emboldening
a short time back.  The current line went from roman to bold to coloured
back to roman, but is now bold.  Bold is fine for me -- actually I quite
like it.

What I have discovered though is that UP-TO-DATE when printed is some
light brown colour that is invisible in my theme.  Can this be made
italic instead?  Or at least something that does not depend on a
specific user theme being in place for the text to be visible.

I am using HEAD of 2010-10-01

--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Colourizing console output

Steve Appling
I don't think I like the defaults either and nothing related to the colors seem be documented in the user guide (not even the command line option).  Since I wanted to change the defaults too, I dug into the source to see what my options were.

There is a --no-color command line option to turn off all colors.

You can set up sytem properties to map the colors to something else.
Set a system property of org.gradle.color.<type>=<color>  
<type> is one of StyledTextOutput.Style:
        normal
        header
        userinput
        identifier
        description
        progressstatus
        failure
        info
        error

<color> is one of Ansi.Color:
        BLACK
        RED
        GREEN
        YELLOW
        BLUE
        MAGENTA
        CYAN
        WHITE
        DEFAULT

It looks like the style type must be all lower case and the color must be all upper case.

Setting these every time as -D options on the command line works but seems unusable.  A better option is probably to put calls to System.setProperty in your init.gradle file (in USER_HOME/.gradle).  It would be perhaps nicer if these could be set in the USER_HOME/gradle.properties file, but I don't think this works currently.

Not all of the output seems to map to the types I would expect.  For example, the list of task names listed from a -t are styled as "userinput", when I was expecting them to be "identifier".  For now, you'll just have to play with it to find out which one influences the output you are trying to impact.  The UP-TO-DATE messages you mentioned are styled using "progressstatus", so you might get what you want by making an init.gradle containing:
   System.setProperty('org.gradle.color.progressstatus', 'BLACK')

On Oct 2, 2010, at 9:31 AM, Russel Winder wrote:

> We had a short discussion about console output colouring and emboldening
> a short time back.  The current line went from roman to bold to coloured
> back to roman, but is now bold.  Bold is fine for me -- actually I quite
> like it.
>
> What I have discovered though is that UP-TO-DATE when printed is some
> light brown colour that is invisible in my theme.  Can this be made
> italic instead?  Or at least something that does not depend on a
> specific user theme being in place for the text to be visible.
>
> I am using HEAD of 2010-10-01
>
> --
> Russel.
> =============================================================================
> Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
> 41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
> London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

--
Steve Appling
Automated Logic Research Team





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Colourizing console output

Steve Appling

On Oct 4, 2010, at 2:30 PM, Steve Appling wrote:

Corrections

> I don't think I like the defaults either and nothing related to the colors seem be documented in the user guide (not even the command line option).


The userguide in the current source does have the command line option '-no-color' listed. I was confused because the 'latest nightly build' userguide on the web site is actually from about 4 weeks ago.  I didn't find any description of how to change the color in the userguide, though.

Also, the option is '-no-color', not '--no-color' as I previously said.

--
Steve Appling
Automated Logic Research Team





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Colourizing console output

Adam Murdoch-3
In reply to this post by Steve Appling

On 05/10/2010, at 5:30 AM, Steve Appling wrote:

I don't think I like the defaults either and nothing related to the colors seem be documented in the user guide (not even the command line option).  Since I wanted to change the defaults too, I dug into the source to see what my options were.

There is a --no-color command line option to turn off all colors.

You can also set TERM=dumb to disable all the dynamic stuff and the colors.


You can set up sytem properties to map the colors to something else.
Set a system property of org.gradle.color.<type>=<color>  
<type> is one of StyledTextOutput.Style:
normal
header
userinput
identifier
description
progressstatus
failure
info
error

There's also 'statusbar' to control the appearance of the progress information at the bottom of the output.


<color> is one of Ansi.Color:
BLACK
RED
GREEN
YELLOW
BLUE
MAGENTA
CYAN
WHITE
DEFAULT

There's also 'bold', 'reverse' and 'italic'


It looks like the style type must be all lower case and the color must be all upper case.

The color is case-insensitive.


Setting these every time as -D options on the command line works but seems unusable.  A better option is probably to put calls to System.setProperty in your init.gradle file (in USER_HOME/.gradle).  It would be perhaps nicer if these could be set in the USER_HOME/gradle.properties file, but I don't think this works currently.

It does work. You need to prefix the system property name with 'systemProp.' as described here: http://www.gradle.org/0.9-rc-1/docs/userguide/tutorial_this_and_that.html#sec:gradle_properties_and_system_properties

The problem with using gradle.properties or init.gradle is that some of the styles are used before these files are applied, and so anything you specify in there will be ignored.

The most reliable way to configure the colors at the moment is to use $GRADLE_OPTS.

None of this is really intended to be the public interface for configuring the output. It's more a simple way to quickly prototype different color schemes for the purposes of figuring out what to hard-code. Hence, no documentation and poor usability. Certainly, use it if you like, but be aware that it may change at any time.

I'm not sure what the public interface might look like. Possibly some API which you can drive from init.gradle. Possibly something in ~/.gradle/gradle.properties (with fixes to load this file as early as possible). Possibly both. Maybe we'll add some general-purpose tasks which let you query and manage various Gradle configuration options, which you could use to configure the output. Maybe we provide a few themes and provide a way to choose which theme to use.



Not all of the output seems to map to the types I would expect.  For example, the list of task names listed from a -t are styled as "userinput", when I was expecting them to be "identifier".

They are 'identifier' now.

 For now, you'll just have to play with it to find out which one influences the output you are trying to impact.  The UP-TO-DATE messages you mentioned are styled using "progressstatus", so you might get what you want by making an init.gradle containing:
  System.setProperty('org.gradle.color.progressstatus', 'BLACK')

On Oct 2, 2010, at 9:31 AM, Russel Winder wrote:

We had a short discussion about console output colouring and emboldening
a short time back.  The current line went from roman to bold to coloured
back to roman, but is now bold.  Bold is fine for me -- actually I quite
like it.

What I have discovered though is that UP-TO-DATE when printed is some
light brown colour that is invisible in my theme.  Can this be made
italic instead?  Or at least something that does not depend on a
specific user theme being in place for the text to be visible.

I am using HEAD of 2010-10-01

--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: <a href="sip:russel.winder@ekiga.net">sip:russel.winder@...
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

--
Steve Appling
Automated Logic Research Team





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply | Threaded
Open this post in threaded view
|

Re: Colourizing console output

Adam Murdoch-3
In reply to this post by Steve Appling

On 05/10/2010, at 6:22 AM, Steve Appling wrote:


On Oct 4, 2010, at 2:30 PM, Steve Appling wrote:

Corrections

I don't think I like the defaults either and nothing related to the colors seem be documented in the user guide (not even the command line option).


The userguide in the current source does have the command line option '-no-color' listed. I was confused because the 'latest nightly build' userguide on the web site is actually from about 4 weeks ago.  I didn't find any description of how to change the color in the userguide, though.

Also, the option is '-no-color', not '--no-color' as I previously said.

Either is fine.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz