maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r423570 - in /maven/shared/trunk/maven-shared-io: ./ src/main/java/org/apache/maven/shared/io/logging/ src/test/java/org/apache/maven/shared/io/logging/
Date Wed, 19 Jul 2006 19:10:04 GMT
Author: jdcasey
Date: Wed Jul 19 12:10:03 2006
New Revision: 423570

URL: http://svn.apache.org/viewvc?rev=423570&view=rev
Log:
Adding multi-channel support for message holders, corresponding to log levels at least initially.

Added:
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
  (with props)
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
  (with props)
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
  (with props)
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java
  (with props)
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
  (with props)
Modified:
    maven/shared/trunk/maven-shared-io/pom.xml
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
    maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
    maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java

Modified: maven/shared/trunk/maven-shared-io/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/pom.xml?rev=423570&r1=423569&r2=423570&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/pom.xml (original)
+++ maven/shared/trunk/maven-shared-io/pom.xml Wed Jul 19 12:10:03 2006
@@ -48,7 +48,19 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>[1.0.4,1.2]</version>
+      <version>1.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-9</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+      <optional>true</optional>
     </dependency>
   </dependencies>
 

Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java?rev=423570&r1=423569&r2=423570&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
(original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
Wed Jul 19 12:10:03 2006
@@ -6,36 +6,75 @@
 import java.util.Iterator;
 import java.util.List;
 
-
 public class DefaultMessageHolder
     implements MessageHolder
 {
-    
+
     private List messages = new ArrayList();
+
     private Message currentMessage;
+    
+    private int defaultMessageLevel = MessageLevels.LEVEL_INFO;
+    
+    private boolean[] messageLevelStates;
+
+    private MessageSink onDemandSink;
+
+    public DefaultMessageHolder()
+    {
+        this.messageLevelStates = MessageLevels.getLevelStates( MessageLevels.LEVEL_INFO
);
+    }
+
+    public DefaultMessageHolder( int maxMessageLevel, int defaultMessageLevel )
+    {
+        this.defaultMessageLevel = defaultMessageLevel;
+        this.messageLevelStates = MessageLevels.getLevelStates( maxMessageLevel );
+    }
+
+    public DefaultMessageHolder( int maxMessageLevel, int defaultMessageLevel, MessageSink
onDemandSink )
+    {
+        this.defaultMessageLevel = defaultMessageLevel;
+        this.onDemandSink = onDemandSink;
+        this.messageLevelStates = MessageLevels.getLevelStates( maxMessageLevel );
+    }
 
     public MessageHolder addMessage( CharSequence messagePart, Throwable error )
     {
-        newMessage();
+        return addMessage( defaultMessageLevel, messagePart, error );
+    }
+    
+    protected MessageHolder addMessage( int level, CharSequence messagePart, Throwable error
)
+    {
+        newMessage( level );
         append( messagePart.toString() );
         append( error );
-        
+
         return this;
     }
 
     public MessageHolder addMessage( CharSequence messagePart )
     {
-        newMessage();
+        return addMessage( defaultMessageLevel, messagePart );
+    }
+    
+    protected MessageHolder addMessage( int level, CharSequence messagePart )
+    {
+        newMessage( level );
         append( messagePart.toString() );
-        
+
         return this;
     }
 
     public MessageHolder addMessage( Throwable error )
     {
-        newMessage();
+        return addMessage( defaultMessageLevel, error );
+    }
+    
+    protected MessageHolder addMessage( int level, Throwable error )
+    {
+        newMessage( level );
         append( error );
-        
+
         return this;
     }
 
@@ -44,10 +83,10 @@
         if ( currentMessage == null )
         {
             newMessage();
-        }        
-        
+        }
+
         currentMessage.append( messagePart.toString() );
-        
+
         return this;
     }
 
@@ -56,10 +95,10 @@
         if ( currentMessage == null )
         {
             newMessage();
-        }        
-        
+        }
+
         currentMessage.setError( error );
-        
+
         return this;
     }
 
@@ -70,35 +109,58 @@
 
     public MessageHolder newMessage()
     {
-        currentMessage = new Message();
-        messages.add( currentMessage );
-        
+        newMessage( defaultMessageLevel );
+
         return this;
     }
+    
+    protected void newMessage( int messageLevel )
+    {
+        if ( onDemandSink != null && currentMessage != null )
+        {
+            renderTo( currentMessage, onDemandSink );
+        }
+        
+        currentMessage = new Message( messageLevel );
+        messages.add( currentMessage );
+    }
 
     public String render()
     {
         StringBuffer buffer = new StringBuffer();
-        
+
         int counter = 1;
         for ( Iterator it = messages.iterator(); it.hasNext(); )
         {
             Message message = (Message) it.next();
             
+            int ml = message.getMessageLevel();
+            
+            if ( ml >= messageLevelStates.length || ml < 0 )
+            {
+                ml = MessageLevels.LEVEL_DEBUG;
+            }
+            
+            if ( !messageLevelStates[ml] )
+            {
+                continue;
+            }
+            
             CharSequence content = message.render();
+            String label = MessageLevels.getLevelLabel( message.getMessageLevel() );
             
-            if ( content.length() > 0 )
+            if ( content.length() > label.length() + 3 )
             {
                 buffer.append( '[' ).append( counter++ ).append( "] " );
                 buffer.append( content.toString() );
-                
+
                 if ( it.hasNext() )
                 {
                     buffer.append( "\n\n" );
                 }
             }
         }
-        
+
         return buffer.toString();
     }
 
@@ -106,50 +168,337 @@
     {
         return messages.size();
     }
-    
+
     private static final class Message
     {
         private StringBuffer message = new StringBuffer();
+
         private Throwable error;
         
+        private final int messageLevel;
+
+        public Message( int messageLevel )
+        {
+            this.messageLevel = messageLevel;
+        }
+
         public Message setError( Throwable error )
         {
             this.error = error;
             return this;
         }
-        
+
         public Message append( CharSequence message )
         {
             this.message.append( message.toString() );
             return this;
         }
         
+        public int getMessageLevel()
+        {
+            return messageLevel;
+        }
+
         public CharSequence render()
         {
             StringBuffer buffer = new StringBuffer();
             
+            buffer.append( '[' ).append( MessageLevels.getLevelLabel( messageLevel ) ).append(
"] " );
+
             if ( message != null && message.length() > 0 )
             {
                 buffer.append( message );
-                
+
                 if ( error != null )
                 {
                     buffer.append( '\n' );
                 }
             }
-            
+
             if ( error != null )
             {
                 buffer.append( "Error:\n" );
-                
+
                 StringWriter sw = new StringWriter();
                 PrintWriter pw = new PrintWriter( sw );
                 error.printStackTrace( pw );
-                
+
                 buffer.append( sw.toString() );
             }
-            
+
             return buffer;
+        }
+    }
+
+    public MessageHolder addDebugMessage( CharSequence messagePart, Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_DEBUG, messagePart, error );
+    }
+
+    public MessageHolder addDebugMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_DEBUG, messagePart );
+    }
+
+    public MessageHolder addDebugMessage( Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_DEBUG, error );
+    }
+
+    public MessageHolder addErrorMessage( CharSequence messagePart, Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_ERROR, messagePart, error );
+    }
+
+    public MessageHolder addErrorMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_ERROR, messagePart );
+    }
+
+    public MessageHolder addErrorMessage( Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_ERROR, error );
+    }
+
+    public MessageHolder addInfoMessage( CharSequence messagePart, Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_INFO, messagePart, error );
+    }
+
+    public MessageHolder addInfoMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_INFO, messagePart );
+    }
+
+    public MessageHolder addInfoMessage( Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_INFO, error );
+    }
+
+    public MessageHolder addSevereMessage( CharSequence messagePart, Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_SEVERE, messagePart, error );
+    }
+
+    public MessageHolder addSevereMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_SEVERE, messagePart );
+    }
+
+    public MessageHolder addSevereMessage( Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_SEVERE, error );
+    }
+
+    public MessageHolder addWarningMessage( CharSequence messagePart, Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_WARNING, messagePart, error );
+    }
+
+    public MessageHolder addWarningMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_WARNING, messagePart );
+    }
+
+    public MessageHolder addWarningMessage( Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_WARNING, error );
+    }
+
+    public int countDebugMessages()
+    {
+        return countMessagesOfType( MessageLevels.LEVEL_DEBUG );
+    }
+
+    public int countErrorMessages()
+    {
+        return countMessagesOfType( MessageLevels.LEVEL_ERROR );
+    }
+
+    public int countInfoMessages()
+    {
+        return countMessagesOfType( MessageLevels.LEVEL_INFO );
+    }
+
+    public int countMessages()
+    {
+        return size();
+    }
+
+    public int countSevereMessages()
+    {
+        return countMessagesOfType( MessageLevels.LEVEL_SEVERE );
+    }
+
+    public int countWarningMessages()
+    {
+        return countMessagesOfType( MessageLevels.LEVEL_WARNING );
+    }
+    
+    private int countMessagesOfType( int messageLevel )
+    {
+        int count = 0;
+        
+        for ( Iterator it = messages.iterator(); it.hasNext(); )
+        {
+            Message message = (Message) it.next();
+            if ( messageLevel == message.getMessageLevel() )
+            {
+                count++;
+            }
+        }
+        
+        return count;
+    }
+
+    public boolean isDebugEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_DEBUG];
+    }
+
+    public boolean isErrorEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_ERROR];
+    }
+
+    public boolean isInfoEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_INFO];
+    }
+
+    public boolean isSevereEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_SEVERE];
+    }
+
+    public boolean isWarningEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_WARNING];
+    }
+
+    public MessageHolder newDebugMessage()
+    {
+        if ( isDebugEnabled() )
+        {
+            newMessage( MessageLevels.LEVEL_DEBUG );
+        }
+        
+        return this;
+    }
+
+    public MessageHolder newErrorMessage()
+    {
+        if ( isErrorEnabled() )
+        {
+            newMessage( MessageLevels.LEVEL_ERROR );
+        }
+        
+        return this;
+    }
+
+    public MessageHolder newInfoMessage()
+    {
+        if ( isInfoEnabled() )
+        {
+            newMessage( MessageLevels.LEVEL_INFO );
+        }
+        
+        return this;
+    }
+
+    public MessageHolder newSevereMessage()
+    {
+        if ( isSevereEnabled() )
+        {
+            newMessage( MessageLevels.LEVEL_SEVERE );
+        }
+        
+        return this;
+    }
+
+    public MessageHolder newWarningMessage()
+    {
+        if ( isWarningEnabled() )
+        {
+            newMessage( MessageLevels.LEVEL_WARNING );
+        }
+        
+        return this;
+    }
+
+    public void setDebugEnabled( boolean enabled )
+    {
+        messageLevelStates[MessageLevels.LEVEL_DEBUG] = enabled;
+    }
+
+    public void setErrorEnabled( boolean enabled )
+    {
+        messageLevelStates[MessageLevels.LEVEL_ERROR] = enabled;
+    }
+
+    public void setInfoEnabled( boolean enabled )
+    {
+        messageLevelStates[MessageLevels.LEVEL_INFO] = enabled;
+    }
+
+    public void setSevereEnabled( boolean enabled )
+    {
+        messageLevelStates[MessageLevels.LEVEL_SEVERE] = enabled;
+    }
+
+    public void setWarningEnabled( boolean enabled )
+    {
+        messageLevelStates[MessageLevels.LEVEL_WARNING] = enabled;
+    }
+    
+    public void flush()
+    {
+        if ( onDemandSink != null && currentMessage != null )
+        {
+            renderTo( currentMessage, onDemandSink );
+            currentMessage = null;
+        }
+    }
+
+    public void render( MessageSink sink )
+    {
+        for ( Iterator it = messages.iterator(); it.hasNext(); )
+        {
+            Message message = (Message) it.next();
+            
+            renderTo( message, sink );
+        }
+    }
+
+    protected void renderTo( Message message, MessageSink sink )
+    {
+        switch( message.getMessageLevel() )
+        {
+        case( MessageLevels.LEVEL_SEVERE ):
+        {
+            sink.severe( message.render().toString() );
+            break;
+        }
+        case( MessageLevels.LEVEL_ERROR ):
+        {
+            sink.error( message.render().toString() );
+            break;
+        }
+        case( MessageLevels.LEVEL_WARNING ):
+        {
+            sink.warning( message.render().toString() );
+            break;
+        }
+        case( MessageLevels.LEVEL_INFO ):
+        {
+            sink.info( message.render().toString() );
+            break;
+        }
+        default:
+        {
+            sink.debug( message.render().toString() );
+            break;
+        }
         }
     }
 

Modified: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java?rev=423570&r1=423569&r2=423570&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
(original)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
Wed Jul 19 12:10:03 2006
@@ -1,10 +1,21 @@
 package org.apache.maven.shared.io.logging;
 
+
 public interface MessageHolder
 {
     
     MessageHolder newMessage();
     
+    MessageHolder newDebugMessage();
+    
+    MessageHolder newInfoMessage();
+    
+    MessageHolder newWarningMessage();
+    
+    MessageHolder newErrorMessage();
+    
+    MessageHolder newSevereMessage();
+    
     MessageHolder append( CharSequence messagePart );
 
     MessageHolder append( Throwable error );
@@ -15,10 +26,76 @@
 
     MessageHolder addMessage( Throwable error );
     
+    MessageHolder addDebugMessage( CharSequence messagePart, Throwable error );
+    
+    MessageHolder addDebugMessage( CharSequence messagePart );
+
+    MessageHolder addDebugMessage( Throwable error );
+    
+    MessageHolder addInfoMessage( CharSequence messagePart, Throwable error );
+    
+    MessageHolder addInfoMessage( CharSequence messagePart );
+
+    MessageHolder addInfoMessage( Throwable error );
+    
+    MessageHolder addWarningMessage( CharSequence messagePart, Throwable error );
+    
+    MessageHolder addWarningMessage( CharSequence messagePart );
+
+    MessageHolder addWarningMessage( Throwable error );
+    
+    MessageHolder addErrorMessage( CharSequence messagePart, Throwable error );
+    
+    MessageHolder addErrorMessage( CharSequence messagePart );
+
+    MessageHolder addErrorMessage( Throwable error );
+    
+    MessageHolder addSevereMessage( CharSequence messagePart, Throwable error );
+    
+    MessageHolder addSevereMessage( CharSequence messagePart );
+
+    MessageHolder addSevereMessage( Throwable error );
+    
     int size();
     
+    int countMessages();
+    
+    int countDebugMessages();
+    
+    int countInfoMessages();
+    
+    int countWarningMessages();
+    
+    int countErrorMessages();
+    
+    int countSevereMessages();
+    
+    boolean isDebugEnabled();
+    
+    void setDebugEnabled( boolean enabled );
+    
+    boolean isInfoEnabled();
+    
+    void setInfoEnabled( boolean enabled );
+    
+    boolean isWarningEnabled();
+    
+    void setWarningEnabled( boolean enabled );
+    
+    boolean isErrorEnabled();
+    
+    void setErrorEnabled( boolean enabled );
+    
+    boolean isSevereEnabled();
+    
+    void setSevereEnabled( boolean enabled );
+    
     boolean isEmpty();
     
     String render();
+    
+    void render( MessageSink sink );
+    
+    void flush();
 
 }

Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java?rev=423570&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
(added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
Wed Jul 19 12:10:03 2006
@@ -0,0 +1,74 @@
+package org.apache.maven.shared.io.logging;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+
+public final class MessageLevels
+{
+
+    public static final int LEVEL_DEBUG = 0;
+    public static final int LEVEL_INFO = 1;
+    public static final int LEVEL_WARNING = 2;
+    public static final int LEVEL_ERROR = 3;
+    public static final int LEVEL_SEVERE = 4;
+    public static final int LEVEL_DISABLED = 5;
+    
+    private static final List LEVEL_NAMES;
+    
+    static
+    {
+        List names = new ArrayList();
+        names.add( "DEBUG" );
+        names.add( "INFO" );
+        names.add( "WARN" );
+        names.add( "ERROR" );
+        names.add( "SEVERE" );
+        
+        LEVEL_NAMES = Collections.unmodifiableList( names );
+    }
+    
+    private MessageLevels()
+    {
+    }
+    
+    public static boolean[] getLevelStates( int maxMessageLevel )
+    {
+        boolean[] states = new boolean[5];
+        
+        Arrays.fill( states, false );
+        
+        switch ( maxMessageLevel )
+        {
+        case (LEVEL_DEBUG): {
+            states[LEVEL_DEBUG] = true;
+        }
+        case (LEVEL_INFO): {
+            states[LEVEL_INFO] = true;
+        }
+        case (LEVEL_WARNING): {
+            states[LEVEL_WARNING] = true;
+        }
+        case (LEVEL_ERROR): {
+            states[LEVEL_ERROR] = true;
+        }
+        case (LEVEL_SEVERE): {
+            states[LEVEL_SEVERE] = true;
+        }
+        }
+        
+        return states;
+    }
+
+    public static String getLevelLabel( int messageLevel )
+    {
+        if ( messageLevel > -1 && LEVEL_NAMES.size() > messageLevel )
+        {
+            return (String) LEVEL_NAMES.get( messageLevel );
+        }
+        
+        throw new IllegalArgumentException( "Invalid message level: " + messageLevel );
+    }
+}

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java?rev=423570&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
(added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
Wed Jul 19 12:10:03 2006
@@ -0,0 +1,17 @@
+package org.apache.maven.shared.io.logging;
+
+
+public interface MessageSink
+{
+    
+    void debug( String message );
+    
+    void info( String message );
+    
+    void warning( String message );
+    
+    void error( String message );
+    
+    void severe( String message );
+
+}

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java?rev=423570&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
(added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
Wed Jul 19 12:10:03 2006
@@ -0,0 +1,42 @@
+package org.apache.maven.shared.io.logging;
+
+import org.apache.maven.plugin.logging.Log;
+
+
+public class MojoLogSink
+    implements MessageSink
+{
+    
+    private final Log logger;
+
+    public MojoLogSink( Log logger )
+    {
+        this.logger = logger;
+    }
+
+    public void debug( String message )
+    {
+        logger.debug( message );
+    }
+
+    public void error( String message )
+    {
+        logger.error( message );
+    }
+
+    public void info( String message )
+    {
+        logger.info( message );
+    }
+
+    public void severe( String message )
+    {
+        logger.error( message );
+    }
+
+    public void warning( String message )
+    {
+        logger.warn( message );
+    }
+
+}

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java?rev=423570&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java
(added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java
Wed Jul 19 12:10:03 2006
@@ -0,0 +1,7 @@
+package org.apache.maven.shared.io.logging;
+
+
+public interface MultiChannelMessageHolder
+{
+
+}

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/MultiChannelMessageHolder.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java?rev=423570&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
(added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
Wed Jul 19 12:10:03 2006
@@ -0,0 +1,42 @@
+package org.apache.maven.shared.io.logging;
+
+import org.codehaus.plexus.logging.Logger;
+
+
+public class PlexusLoggerSink
+    implements MessageSink
+{
+    
+    private final Logger logger;
+
+    public PlexusLoggerSink( Logger logger )
+    {
+        this.logger = logger;
+    }
+
+    public void debug( String message )
+    {
+        logger.debug( message );
+    }
+
+    public void error( String message )
+    {
+        logger.error( message );
+    }
+
+    public void info( String message )
+    {
+        logger.info( message );
+    }
+
+    public void severe( String message )
+    {
+        logger.fatalError( message );
+    }
+
+    public void warning( String message )
+    {
+        logger.warn( message );
+    }
+
+}

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java?rev=423570&r1=423569&r2=423570&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
(original)
+++ maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
Wed Jul 19 12:10:03 2006
@@ -42,7 +42,7 @@
 
         assertEquals( 1, mh.size() );
 
-        assertEquals( "[1] test", mh.render() );
+        assertEquals( "[1] [INFO] test", mh.render() );
     }
 
     // MessageHolder append( Throwable error );
@@ -67,7 +67,7 @@
         
         npe.printStackTrace( pw );
 
-        assertEquals( "[1] Error:\n" + sw.toString(), mh.render() );
+        assertEquals( "[1] [INFO] Error:\n" + sw.toString(), mh.render() );
     }
 
     // MessageHolder newMessage();
@@ -90,7 +90,7 @@
 
         assertEquals( 1, mh.size() );
 
-        assertEquals( "[1] test", mh.render() );
+        assertEquals( "[1] [INFO] test", mh.render() );
     }
 
     // MessageHolder newMessage();
@@ -118,7 +118,7 @@
 
         assertEquals( 1, mh.size() );
 
-        assertEquals( "[1] test again", mh.render() );
+        assertEquals( "[1] [INFO] test again", mh.render() );
     }
 
     // MessageHolder newMessage();
@@ -153,7 +153,7 @@
         
         npe.printStackTrace( pw );
 
-        assertEquals( "[1] test\nError:\n" + sw.toString(), mh.render() );
+        assertEquals( "[1] [INFO] test\nError:\n" + sw.toString(), mh.render() );
     }
     
     // MessageHolder addMessage( CharSequence messagePart );
@@ -167,7 +167,7 @@
         assertSame( mh, check );
         
         assertEquals( 1, mh.size() );
-        assertEquals( "[1] test", mh.render() );
+        assertEquals( "[1] [INFO] test", mh.render() );
     }
     
     // MessageHolder addMessage( CharSequence messagePart );
@@ -185,7 +185,7 @@
         assertSame( mh, check );
         
         assertEquals( 2, mh.size() );
-        assertEquals( "[1] test\n\n[2] test2", mh.render() );
+        assertEquals( "[1] [INFO] test\n\n[2] [INFO] test2", mh.render() );
     }
     
     // MessageHolder addMessage( CharSequence messagePart, Throwable error );
@@ -208,7 +208,7 @@
         
         npe.printStackTrace( pw );
 
-        assertEquals( "[1] test\nError:\n" + sw.toString(), mh.render() );
+        assertEquals( "[1] [INFO] test\nError:\n" + sw.toString(), mh.render() );
     }
     
     // MessageHolder addMessage( CharSequence messagePart, Throwable error );
@@ -236,7 +236,7 @@
         
         npe.printStackTrace( pw );
 
-        assertEquals( "[1] test\nError:\n" + sw.toString() + "\n\n[2] test2", mh.render()
);
+        assertEquals( "[1] [INFO] test\nError:\n" + sw.toString() + "\n\n[2] [INFO] test2",
mh.render() );
     }
     
     // MessageHolder addMessage( Throwable error );
@@ -259,7 +259,7 @@
         
         npe.printStackTrace( pw );
 
-        assertEquals( "[1] Error:\n" + sw.toString(), mh.render() );
+        assertEquals( "[1] [INFO] Error:\n" + sw.toString(), mh.render() );
     }
     
     // boolean isEmpty();



Mime
View raw message