You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jdillon <gi...@git.apache.org> on 2016/05/16 19:43:33 UTC

[GitHub] maven pull request: Hook up gossip as slf4j backend and implement ...

GitHub user jdillon opened a pull request:

    https://github.com/apache/maven/pull/81

    Hook up gossip as slf4j backend and implement customized color renderer

    Replaces slf4j-simple with gossip-slf4j ( https://github.com/jdillon/gossip ) and adds support for colorized output.
    
    ![maven-color](https://cloud.githubusercontent.com/assets/20114/15301594/53c3be3c-1b63-11e6-90e6-e44a4d7e1f2f.png)
    
    To enable colorized output:
    
    ```
    MAVEN_OPTS="-Dmaven.logging=color" bin/mvn
    ```
    
    or set in ~/.mavenrc
    
    Presently has to be passed in via MAVEN_OPTS as there is no context to access the -D flags early enough to configure the backend w/o more changes to the Slf4jConfiguration api.
    
    Default is presently plain, so users need to elect to use color explicitly as described above.
    
    Colorization is a subset of the color handling available in mvnsh, as this can only colorize log events, so anything going directly to output streams (like bits from surefire, etc) can not be colorized by this mechanism.
    
    Left the assembly conf/logging/* bits alone, as its not clear if other configurations are expecting this directory to exist or not, but likely should be cleaned up.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jdillon/maven gossip-slf4j-backend

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/maven/pull/81.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #81
    
----
commit bedba47f7ac1275502ae0ab1ec9e2c291921674f
Author: Jason Dillon <ja...@planet57.com>
Date:   2016-05-16T19:34:21Z

    Hook up gossip as slf4j backend and implement customized color renderer

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request #81: Hook up gossip as slf4j backend and implement custom...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/maven/pull/81


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220743522
  
    @michael-o w/o making more of the embedder aware of potential colorization its not easy to do.  I will push an example which should make > and -l work but it does involve adding a system property when the -l option is processed to strip out ansi.
    
    The slf4j logging configuration presently does not have any context of the cli options, so its hard to make it fully aware of the configuration w/o such hacks, or potentially augmenting the api to configure.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220746222
  
    @michael-o yup, that is what is used internally by AnsiConsole.wrapOutputStream() to _help_ detect if it should strip sequences or not, but its not a proper public api to consume directly atm.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by michael-o <gi...@git.apache.org>.
Github user michael-o commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220746502
  
    Yes, leave it to JAnsi to decide. Just noticed that they do not provide a native package for FreeBSD. Will reach out to them next week.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on a diff in the pull request:

    https://github.com/apache/maven/pull/81#discussion_r64118607
  
    --- Diff: pom.xml ---
    @@ -282,6 +282,16 @@
             <version>1.1.7</version>
             <optional>true</optional>
           </dependency>
    +      <dependency>
    +        <groupId>org.sonatype.gossip</groupId>
    +        <artifactId>gossip-slf4j</artifactId>
    +        <version>1.9-SNAPSHOT</version>
    --- End diff --
    
    Yup, working on that; marked the PR as WIP until I can get this sorted out


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by michael-o <gi...@git.apache.org>.
Github user michael-o commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220746069
  
    It seems there is some magic: https://github.com/fusesource/jansi-native/blob/master/src/main/java/org/fusesource/jansi/internal/CLibrary.java#L59


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: Hook up gossip as slf4j backend and implement ...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220737076
  
    Pending a groupId update to get a release of gossip which has a few minor bug fixes to make the core-it-suite happy.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-221379335
  
    Updated gossip to 2.0.0 which is now in com.planet57 namespace and I can make a release of it shortly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven issue #81: Hook up gossip as slf4j backend and implement customized co...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the issue:

    https://github.com/apache/maven/pull/81
  
    @jvanzyl I believe the output issues were sorted, but was still seeing some odd failures with what looked like resolution mismatches, downloading a version of one artifact but ending up with a slightly different version.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by michael-o <gi...@git.apache.org>.
Github user michael-o commented on a diff in the pull request:

    https://github.com/apache/maven/pull/81#discussion_r64118541
  
    --- Diff: pom.xml ---
    @@ -282,6 +282,16 @@
             <version>1.1.7</version>
             <optional>true</optional>
           </dependency>
    +      <dependency>
    +        <groupId>org.sonatype.gossip</groupId>
    +        <artifactId>gossip-slf4j</artifactId>
    +        <version>1.9-SNAPSHOT</version>
    --- End diff --
    
    This should resolve to a release version.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven issue #81: Hook up gossip as slf4j backend and implement customized co...

Posted by hboutemy <gi...@git.apache.org>.
Github user hboutemy commented on the issue:

    https://github.com/apache/maven/pull/81
  
    I just committed the code, slightly modified since Maven general color support was added in MNG-3507 (after extracting some code from this provider)
    I tested with core ITs and fixed one little issue in error rendering: there was one missing ":" after "Caused by": nothing complex, but this caused failures in ITs that were checking stacktrace content :)
    
    Thank you Jason D: now we'll see if everybody is ok to use the provider as default...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220744680
  
    @michael-o the jansi library has some limited support to detect tty when wrapping and potentially strip sequenced.  I've pushed a change which makes the gossip listener aware of ansi by default and will escape by default when using > and in the case of -l I had to add a minor hack to force it to strip via system property.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: Hook up gossip as slf4j backend and implement ...

Posted by jdillon <gi...@git.apache.org>.
Github user jdillon commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-221441322
  
    Updated gossip to 2.0.0 release which is now in central.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request #81: Hook up gossip as slf4j backend and implement custom...

Posted by hboutemy <gi...@git.apache.org>.
Github user hboutemy commented on a diff in the pull request:

    https://github.com/apache/maven/pull/81#discussion_r66704747
  
    --- Diff: maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/ColorRenderer.java ---
    @@ -0,0 +1,165 @@
    +package org.apache.maven.cli.logging.impl.gossip;
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +import static org.fusesource.jansi.Ansi.Attribute.INTENSITY_BOLD;
    +import static org.fusesource.jansi.Ansi.Color.CYAN;
    +import static org.fusesource.jansi.Ansi.Color.GREEN;
    +import static org.fusesource.jansi.Ansi.Color.RED;
    +import static org.fusesource.jansi.Ansi.Color.YELLOW;
    +import static org.fusesource.jansi.Ansi.ansi;
    +
    +import com.planet57.gossip.Event;
    +import com.planet57.gossip.Level;
    +
    +/**
    + * Specialized {@link com.planet57.gossip.render.Renderer} which is aware of basic Maven log messages to colorize.
    + *
    + * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
    + * @since 3.4.0
    + */
    +public class ColorRenderer
    +    extends PatternRenderer
    +{
    +    @Override
    +    protected void renderLevel( final Event event, final StringBuilder buff )
    +    {
    +        assert event != null;
    +        assert buff != null;
    +
    +        Level level = event.getLevel();
    +        switch ( level )
    +        {
    +            case TRACE:
    +            case DEBUG:
    +                buff.append( ansi().a( INTENSITY_BOLD ).fg( YELLOW ).a( level.name() ).reset() );
    +                break;
    +
    +            case INFO:
    +                buff.append( ansi().a( INTENSITY_BOLD ).fg( GREEN ).a( level.name() ).reset() );
    +                break;
    +
    +            case WARN:
    +                // Maven uses WARNING instead of WARN
    +                buff.append( ansi().a( INTENSITY_BOLD ).fg( RED ).a( WARNING ).reset() );
    +                break;
    +
    +            case ERROR:
    +                buff.append( ansi().a( INTENSITY_BOLD ).fg( RED ).a( level.name() ).reset() );
    +                break;
    +
    +            default:
    +                throw new InternalError();
    +        }
    +    }
    +
    +    @Override
    +    protected void renderName( final Event event, final StringBuilder buff, final boolean shortName )
    +    {
    +        StringBuilder tmp = new StringBuilder();
    +        super.renderName( event, tmp, shortName );
    +        buff.append( ansi().fg( GREEN ).a( tmp ).reset() );
    +    }
    +
    +    @Override
    +    protected void renderMessage( final Event event, final StringBuilder buff )
    +    {
    +        final String message = event.getMessage();
    +
    +        if ( message.startsWith( "------------------------------------------------------------------------" ) )
    +        {
    +            buff.append( ansi().a( INTENSITY_BOLD ).a( message ).reset() );
    +        }
    +        else if ( message.startsWith( "---" ) && message.endsWith( " ---" ) )
    +        {
    +            String[] items = message.split( "\\s" );
    +            buff.append( ansi().a( INTENSITY_BOLD ).a( "---" ).reset() );
    +            buff.append( " " );
    +            buff.append( ansi().fg( GREEN ).a( items[1] ).reset() );
    +            buff.append( " " );
    +            buff.append( ansi().a( INTENSITY_BOLD ).a( items[2] ).reset() );
    +            buff.append( " @ " );
    +            buff.append( ansi().fg( CYAN ).a( items[4] ).reset() );
    +            buff.append( ansi().a( INTENSITY_BOLD ).a( " ---" ).reset() );
    +        }
    +        else if ( message.contains( "ERROR" ) || message.contains( "FAILURE" ) || message.contains( "FAILED" ) )
    +        {
    +            buff.append( ansi().a( INTENSITY_BOLD ).fg( RED ).a( message ).reset() );
    +        }
    +        else if ( message.contains( "BUILD SUCCESS" ) )
    +        {
    +            buff.append( ansi().a( INTENSITY_BOLD ).fg( GREEN ).a( message ).reset() );
    +        }
    +        else if ( message.contains( "SUCCESS" ) )
    +        {
    +            buff.append( ansi().fg( GREEN ).a( message ).reset() );
    +        }
    +        else
    +        {
    +            buff.append( message );
    +        }
    +    }
    +
    +    @Override
    +    protected void renderCause( final Event event, final StringBuilder buff )
    +    {
    +        assert event != null;
    +        assert buff != null;
    +
    +        Throwable cause = event.getCause();
    +        if ( cause == null )
    +        {
    +            return;
    +        }
    +
    +        buff.append( ansi().a( INTENSITY_BOLD ).fg( RED ).a( cause.getClass().getName() ).reset() );
    +        if ( cause.getMessage() != null )
    +        {
    +            buff.append( ": " );
    +            buff.append( ansi().a( INTENSITY_BOLD ).fg( RED ).a( cause.getMessage() ).reset() );
    +        }
    +        renderNewLine( buff );
    +
    +        while ( cause != null )
    +        {
    +            for ( StackTraceElement e : cause.getStackTrace() )
    +            {
    +                buff.append( "    " );
    +                buff.append( ansi().a( INTENSITY_BOLD ).a( "at" ).reset().a( " " )
    +                        .a( e.getClassName() ).a( "." ).a( e.getMethodName() ) );
    +                buff.append( ansi().a( " (" ).a( INTENSITY_BOLD ).a( getLocation( e ) ).reset().a( ")" ) );
    +                renderNewLine( buff );
    +            }
    +
    +            cause = cause.getCause();
    +            if ( cause != null )
    +            {
    +                buff.append( ansi().a( INTENSITY_BOLD ).a( "Caused by" ).reset().a( " " )
    --- End diff --
    
    should be a( "Caused by" ).reset().a( ": " )
    fixed while merging in Maven


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven issue #81: Hook up gossip as slf4j backend and implement customized co...

Posted by jvanzyl <gi...@git.apache.org>.
Github user jvanzyl commented on the issue:

    https://github.com/apache/maven/pull/81
  
    How are the ITs looking now? I know there were a few issues with the output not matching slf4j-simple that you were trying to sort out.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by michael-o <gi...@git.apache.org>.
Github user michael-o commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220743917
  
    I know, that is why I have asked for. You may check out the link I have provided. This might help. Probably you should mention this limitation in your docs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: [WIP] Hook up gossip as slf4j backend and impl...

Posted by michael-o <gi...@git.apache.org>.
Github user michael-o commented on the pull request:

    https://github.com/apache/maven/pull/81#issuecomment-220738504
  
    What happens if the opts are set but `-l` or `>` is used? Do you detect that `System.out` is not a terminal?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org