1 package org.apache.maven.plugin.surefire.log.api;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public final class ConsoleLoggerDecorator
30 implements ConsoleLogger
31 {
32 private final Object logger;
33
34 public ConsoleLoggerDecorator( Object logger )
35 {
36 if ( logger == null )
37 {
38 throw new NullPointerException( "logger argument is null in " + ConsoleLoggerDecorator.class );
39 }
40 this.logger = logger;
41 }
42
43 public void debug( String message )
44 {
45 try
46 {
47 logger.getClass()
48 .getMethod( "debug", String.class )
49 .invoke( logger, message );
50 }
51 catch ( Exception e )
52 {
53 throw new IllegalStateException( e.getLocalizedMessage(), e );
54 }
55 }
56
57 public void info( String message )
58 {
59 try
60 {
61 logger.getClass()
62 .getMethod( "info", String.class )
63 .invoke( logger, message );
64 }
65 catch ( Exception e )
66 {
67 throw new IllegalStateException( e.getLocalizedMessage(), e );
68 }
69 }
70
71 public void warning( String message )
72 {
73 try
74 {
75 logger.getClass()
76 .getMethod( "warning", String.class )
77 .invoke( logger, message );
78 }
79 catch ( Exception e )
80 {
81 throw new IllegalStateException( e.getLocalizedMessage(), e );
82 }
83 }
84
85 public void error( String message )
86 {
87 try
88 {
89 logger.getClass()
90 .getMethod( "error", String.class )
91 .invoke( logger, message );
92 }
93 catch ( Exception e )
94 {
95 throw new IllegalStateException( e.getLocalizedMessage(), e );
96 }
97 }
98
99 public void error( String message, Throwable t )
100 {
101 try
102 {
103 logger.getClass()
104 .getMethod( "error", String.class, Throwable.class )
105 .invoke( logger, message, t );
106 }
107 catch ( Exception e )
108 {
109 throw new IllegalStateException( e.getLocalizedMessage(), e );
110 }
111 }
112
113 public void error( Throwable t )
114 {
115 try
116 {
117 logger.getClass()
118 .getMethod( "error", Throwable.class )
119 .invoke( logger, t );
120 }
121 catch ( Exception e )
122 {
123 throw new IllegalStateException( e.getLocalizedMessage(), e );
124 }
125 }
126 }