1 package org.eclipse.aether.internal.test.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.PrintStream;
23
24 import org.eclipse.aether.spi.log.Logger;
25 import org.eclipse.aether.spi.log.LoggerFactory;
26
27
28
29
30 public final class TestLoggerFactory
31 implements LoggerFactory
32 {
33
34 private final Logger logger;
35
36
37
38
39 public TestLoggerFactory()
40 {
41 this( null );
42 }
43
44
45
46
47 public TestLoggerFactory( PrintStream out )
48 {
49 logger = new TestLogger( out );
50 }
51
52 public Logger getLogger( String name )
53 {
54 return logger;
55 }
56
57 private static final class TestLogger
58 implements Logger
59 {
60
61 private final PrintStream out;
62
63 TestLogger( PrintStream out )
64 {
65 this.out = ( out != null ) ? out : System.out;
66 }
67
68 public boolean isWarnEnabled()
69 {
70 return true;
71 }
72
73 public void warn( String msg, Throwable error )
74 {
75 out.println( "[WARN] " + msg );
76 if ( error != null )
77 {
78 error.printStackTrace( out );
79 }
80 }
81
82 public void warn( String msg )
83 {
84 warn( msg, null );
85 }
86
87 public boolean isDebugEnabled()
88 {
89 return true;
90 }
91
92 public void debug( String msg, Throwable error )
93 {
94 out.println( "[DEBUG] " + msg );
95 if ( error != null )
96 {
97 error.printStackTrace( out );
98 }
99 }
100
101 public void debug( String msg )
102 {
103 debug( msg, null );
104 }
105
106 }
107
108 }