Class LogCapturer

  • All Implemented Interfaces:
    java.util.EventListener, org.apache.tools.ant.BuildListener

    public class LogCapturer
    extends java.lang.Object
    implements org.apache.tools.ant.BuildListener
    Captures log messages generated during an antunit task run and makes them available to tasks via a project reference.

    This class captures all messages generated during the build and adds itself as project reference to the project using the id ant.antunit.log.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String REFERENCE_ID  
    • Constructor Summary

      Constructors 
      Constructor Description
      LogCapturer​(org.apache.tools.ant.Project p)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildFinished​(org.apache.tools.ant.BuildEvent event)
      De-register.
      void buildStarted​(org.apache.tools.ant.BuildEvent event)
      Empty.
      java.lang.String getDebugLog()
      All messages with logLevel == Project.MSG_DEBUG or more severe merging messages into a single line.
      java.lang.String getDebugLog​(boolean mergeLines)
      All messages with logLevel == Project.MSG_DEBUG or more severe.
      java.lang.String getErrLog()
      All messages with logLevel == Project.MSG_ERR merging messages into a single line.
      java.lang.String getErrLog​(boolean mergeLines)
      All messages with logLevel == Project.MSG_ERR.
      java.lang.String getInfoLog()
      All messages with logLevel == Project.MSG_INFO or more severe merging messages into a single line.
      java.lang.String getInfoLog​(boolean mergeLines)
      All messages with logLevel == Project.MSG_INFO or more severe.
      java.lang.String getVerboseLog()
      All messages with logLevel == Project.MSG_VERBOSE or more severe merging messages into a single line.
      java.lang.String getVerboseLog​(boolean mergeLines)
      All messages with logLevel == Project.MSG_VERBOSE or more severe.
      java.lang.String getWarnLog()
      All messages with logLevel == Project.MSG_WARN or more severe merging messages into a single line.
      java.lang.String getWarnLog​(boolean mergeLines)
      All messages with logLevel == Project.MSG_WARN or more severe.
      void messageLogged​(org.apache.tools.ant.BuildEvent event)
      Record the message.
      void targetFinished​(org.apache.tools.ant.BuildEvent event)
      Empty.
      void targetStarted​(org.apache.tools.ant.BuildEvent event)
      Empty.
      void taskFinished​(org.apache.tools.ant.BuildEvent event)
      Empty.
      void taskStarted​(org.apache.tools.ant.BuildEvent event)
      Empty.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LogCapturer

        public LogCapturer​(org.apache.tools.ant.Project p)
    • Method Detail

      • getErrLog

        public java.lang.String getErrLog()
        All messages with logLevel == Project.MSG_ERR merging messages into a single line.
        Returns:
        All messages with logLevel == Project.MSG_ERR
      • getWarnLog

        public java.lang.String getWarnLog()
        All messages with logLevel == Project.MSG_WARN or more severe merging messages into a single line.
        Returns:
        All messages with logLevel == Project.MSG_WARN or above
      • getInfoLog

        public java.lang.String getInfoLog()
        All messages with logLevel == Project.MSG_INFO or more severe merging messages into a single line.
        Returns:
        All messages with logLevel == Project.MSG_INFO or above
      • getVerboseLog

        public java.lang.String getVerboseLog()
        All messages with logLevel == Project.MSG_VERBOSE or more severe merging messages into a single line.
        Returns:
        All messages with logLevel == Project.MSG_VERBOSE or above
      • getDebugLog

        public java.lang.String getDebugLog()
        All messages with logLevel == Project.MSG_DEBUG or more severe merging messages into a single line.
        Returns:
        All messages with logLevel == Project.MSG_DEBUG or above
      • getErrLog

        public java.lang.String getErrLog​(boolean mergeLines)
        All messages with logLevel == Project.MSG_ERR.
        Parameters:
        mergeLines - whether to merge messages into a single line or split them into multiple lines
        Returns:
        All messages with logLevel == Project.MSG_ERR
      • getWarnLog

        public java.lang.String getWarnLog​(boolean mergeLines)
        All messages with logLevel == Project.MSG_WARN or more severe.
        Parameters:
        mergeLines - whether to merge messages into a single line or split them into multiple lines
        Returns:
        All messages with logLevel == Project.MSG_WARN or above
        Since:
        AntUnit 1.3
      • getInfoLog

        public java.lang.String getInfoLog​(boolean mergeLines)
        All messages with logLevel == Project.MSG_INFO or more severe.
        Parameters:
        mergeLines - whether to merge messages into a single line or split them into multiple lines
        Returns:
        All messages with logLevel == Project.MSG_INFO or above
        Since:
        AntUnit 1.3
      • getVerboseLog

        public java.lang.String getVerboseLog​(boolean mergeLines)
        All messages with logLevel == Project.MSG_VERBOSE or more severe.
        Parameters:
        mergeLines - whether to merge messages into a single line or split them into multiple lines
        Returns:
        All messages with logLevel == Project.MSG_VERBOSE or above
        Since:
        AntUnit 1.3
      • getDebugLog

        public java.lang.String getDebugLog​(boolean mergeLines)
        All messages with logLevel == Project.MSG_DEBUG or more severe.
        Parameters:
        mergeLines - whether to merge messages into a single line or split them into multiple lines
        Returns:
        All messages with logLevel == Project.MSG_DEBUG or above
        Since:
        AntUnit 1.3
      • buildStarted

        public void buildStarted​(org.apache.tools.ant.BuildEvent event)
        Empty.
        Specified by:
        buildStarted in interface org.apache.tools.ant.BuildListener
      • targetStarted

        public void targetStarted​(org.apache.tools.ant.BuildEvent event)
        Empty.
        Specified by:
        targetStarted in interface org.apache.tools.ant.BuildListener
      • targetFinished

        public void targetFinished​(org.apache.tools.ant.BuildEvent event)
        Empty.
        Specified by:
        targetFinished in interface org.apache.tools.ant.BuildListener
      • taskStarted

        public void taskStarted​(org.apache.tools.ant.BuildEvent event)
        Empty.
        Specified by:
        taskStarted in interface org.apache.tools.ant.BuildListener
      • taskFinished

        public void taskFinished​(org.apache.tools.ant.BuildEvent event)
        Empty.
        Specified by:
        taskFinished in interface org.apache.tools.ant.BuildListener
      • buildFinished

        public void buildFinished​(org.apache.tools.ant.BuildEvent event)
        De-register.
        Specified by:
        buildFinished in interface org.apache.tools.ant.BuildListener
      • messageLogged

        public void messageLogged​(org.apache.tools.ant.BuildEvent event)
        Record the message.
        Specified by:
        messageLogged in interface org.apache.tools.ant.BuildListener