View Javadoc

1   package org.codehaus.mojo.fitnesse.log;
2   
3   /*
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, version 2.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU General Public License for more details.
12   *
13   * You should have received a copy of the GNU General Public License
14   * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
15   */
16  
17  import java.util.logging.Level;
18  
19  import org.apache.maven.plugin.logging.Log;
20  
21  public class LogConsumer
22      implements FitnesseStreamConsumer
23  {
24  
25      private Log mLog;
26  
27      private Level mLevel;
28  
29      private boolean mHasGeneratedResultFile = false;
30  
31      /** Only for test. */
32      public LogConsumer()
33      {
34      }
35  
36      public LogConsumer( Log pLog, Level pLevel )
37      {
38          super();
39          mLog = pLog;
40          mLevel = pLevel;
41      }
42  
43      public void consumeLine( String pMessage )
44      {
45          if ( Level.INFO.equals( mLevel ) )
46          {
47              mLog.info( pMessage );
48          }
49          else
50          {
51              mLog.error( pMessage );
52          }
53          mHasGeneratedResultFile = mHasGeneratedResultFile || pMessage.startsWith( "Formatting as html" );
54  
55      }
56  
57      public boolean hasGeneratedResultFile()
58      {
59          return mHasGeneratedResultFile;
60      }
61  
62      public Level getLevel()
63      {
64          return mLevel;
65      }
66  
67  }