maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject [43/50] maven git commit: Add custom renderer to cope with Maven using WARNING instead of WARN
Date Thu, 02 Jun 2016 22:09:28 GMT
Add custom renderer to cope with Maven using WARNING instead of WARN


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/e50b95f5
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/e50b95f5
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/e50b95f5

Branch: refs/heads/slf4j-gossip
Commit: e50b95f5a2c9003fc11466ef09346acd2e2bc485
Parents: 8781dc3
Author: Jason Dillon <jason@planet57.com>
Authored: Fri May 20 13:12:15 2016 -0700
Committer: Hervé Boutemy <hboutemy@apache.org>
Committed: Thu Jun 2 23:41:45 2016 +0200

----------------------------------------------------------------------
 .../cli/logging/impl/gossip/ColorRenderer.java  | 15 ++++--
 .../logging/impl/gossip/PatternRenderer.java    | 54 ++++++++++++++++++++
 .../org.sonatype.gossip/config.properties       |  4 +-
 3 files changed, 66 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/e50b95f5/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/ColorRenderer.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/ColorRenderer.java
b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/ColorRenderer.java
index f844c04..8a03a55 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/ColorRenderer.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/ColorRenderer.java
@@ -27,7 +27,7 @@ import static org.fusesource.jansi.Ansi.Color.YELLOW;
 import static org.fusesource.jansi.Ansi.ansi;
 
 import org.sonatype.gossip.Event;
-import org.sonatype.gossip.render.PatternRenderer;
+import org.sonatype.gossip.Level;
 
 /**
  * Specialized {@link org.sonatype.gossip.render.Renderer} which is aware of basic Maven
log messages to colorize.
@@ -44,20 +44,25 @@ public class ColorRenderer
         assert event != null;
         assert buff != null;
 
-        switch ( event.getLevel() )
+        Level level = event.getLevel();
+        switch ( level )
         {
             case TRACE:
             case DEBUG:
-                buff.append( ansi().a( INTENSITY_BOLD ).fg( YELLOW ).a( event.getLevel().name()
).reset() );
+                buff.append( ansi().a( INTENSITY_BOLD ).fg( YELLOW ).a( level.name() ).reset()
);
                 break;
 
             case INFO:
-                buff.append( ansi().a( INTENSITY_BOLD ).fg( GREEN ).a( event.getLevel().name()
).reset() );
+                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( event.getLevel().name()
).reset() );
+                buff.append( ansi().a( INTENSITY_BOLD ).fg( RED ).a( level.name() ).reset()
);
                 break;
 
             default:

http://git-wip-us.apache.org/repos/asf/maven/blob/e50b95f5/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/PatternRenderer.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/PatternRenderer.java
b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/PatternRenderer.java
new file mode 100644
index 0000000..7e767a1
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/gossip/PatternRenderer.java
@@ -0,0 +1,54 @@
+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 org.sonatype.gossip.Event;
+import org.sonatype.gossip.Level;
+
+/**
+ * Specialized {@link org.sonatype.gossip.render.PatternRenderer} to cope with Maven specifics.
+ *
+ * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
+ * @since 3.4.0
+ */
+public class PatternRenderer
+    extends org.sonatype.gossip.render.PatternRenderer
+{
+    protected static final String WARNING = "WARNING";
+
+    @Override
+    protected void renderLevel( final Event event, final StringBuilder buff )
+    {
+        assert event != null;
+        assert buff != null;
+
+        Level level = event.getLevel();
+
+        // Maven uses WARNING instead of WARN
+        if ( level == Level.WARN )
+        {
+            buff.append( WARNING );
+        }
+        else
+        {
+            buff.append( level.name() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/e50b95f5/maven-embedder/src/main/resources/META-INF/org.sonatype.gossip/config.properties
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/resources/META-INF/org.sonatype.gossip/config.properties
b/maven-embedder/src/main/resources/META-INF/org.sonatype.gossip/config.properties
index a830b1e..acec235 100644
--- a/maven-embedder/src/main/resources/META-INF/org.sonatype.gossip/config.properties
+++ b/maven-embedder/src/main/resources/META-INF/org.sonatype.gossip/config.properties
@@ -26,7 +26,7 @@ profiles=default, maven-common, maven-plain, maven-color
 profile.default.includes=maven-common
 profile.default.listeners=console
 profile.default.listener.console=org.sonatype.gossip.listener.ConsoleListener
-profile.default.listener.console.renderer=org.sonatype.gossip.render.PatternRenderer
+profile.default.listener.console.renderer=org.apache.maven.cli.logging.impl.gossip.PatternRenderer
 profile.default.listener.console.renderer.pattern=[%l] %m%n%x
 
 ##
@@ -42,7 +42,7 @@ profile.maven-common.logger.*=INFO
 profile.maven-plain.includes=maven-common
 profile.maven-plain.listeners=console
 profile.maven-plain.listener.console=org.sonatype.gossip.listener.ConsoleListener
-profile.maven-plain.listener.console.renderer=org.sonatype.gossip.render.PatternRenderer
+profile.maven-plain.listener.console.renderer=org.apache.maven.cli.logging.impl.gossip.PatternRenderer
 profile.maven-plain.listener.console.renderer.pattern=[%l] %m%n%x
 profile.maven-plain.triggers=default
 profile.maven-plain.trigger.default=org.sonatype.gossip.trigger.SystemPropertyTrigger


Mime
View raw message