1 package org.codehaus.mojo.clirr;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import net.sf.clirr.core.ApiDifference;
20 import net.sf.clirr.core.DiffListenerAdapter;
21 import net.sf.clirr.core.MessageTranslator;
22 import net.sf.clirr.core.Severity;
23 import org.apache.maven.plugin.logging.Log;
24
25
26
27
28
29
30 public class LogDiffListener
31 extends DiffListenerAdapter
32 {
33 private final Log log;
34
35 private final MessageTranslator messageTranslator;
36
37 public LogDiffListener( Log log )
38 {
39 this.log = log;
40
41 this.messageTranslator = new MessageTranslator();
42 }
43
44 public void reportDiff( ApiDifference apiDifference )
45 {
46 String message = apiDifference.getMessage().getId() + ": " + apiDifference.getAffectedClass() + ": " +
47 apiDifference.getReport( messageTranslator );
48
49 Severity severity = apiDifference.getMaximumSeverity();
50 if ( severity.equals( Severity.INFO ) )
51 {
52 log.info( message );
53 }
54 else if ( severity.equals( Severity.WARNING ) )
55 {
56 log.warn( message );
57 }
58 else if ( severity.equals( Severity.ERROR ) )
59 {
60 log.error( message );
61 }
62 }
63 }