1 package org.apache.maven.surefire.booter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.surefire.util.internal.DumpFileUtils;
23
24 import java.io.File;
25
26 import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
27
28
29
30
31
32
33
34
35 public final class DumpErrorSingleton
36 {
37 public static final String DUMP_FILE_EXT = ".dump";
38 public static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
39 private static final DumpErrorSingleton SINGLETON = new DumpErrorSingleton();
40
41 private File dumpFile;
42 private File dumpStreamFile;
43
44 private DumpErrorSingleton()
45 {
46 }
47
48 public static DumpErrorSingleton getSingleton()
49 {
50 return SINGLETON;
51 }
52
53 public synchronized void init( File reportsDir, String dumpFileName )
54 {
55 dumpFile = createDumpFile( reportsDir, dumpFileName );
56 dumpStreamFile = createDumpStreamFile( reportsDir, dumpFileName );
57 }
58
59 public synchronized void dumpException( Throwable t, String msg )
60 {
61 DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpFile );
62 }
63
64 public synchronized void dumpException( Throwable t )
65 {
66 DumpFileUtils.dumpException( t, dumpFile );
67 }
68
69 public synchronized void dumpText( String msg )
70 {
71 DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpFile );
72 }
73
74 public synchronized void dumpStreamException( Throwable t, String msg )
75 {
76 DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpStreamFile );
77 }
78
79 public synchronized void dumpStreamException( Throwable t )
80 {
81 DumpFileUtils.dumpException( t, dumpStreamFile );
82 }
83
84 public synchronized void dumpStreamText( String msg )
85 {
86 DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpStreamFile );
87 }
88
89 private File createDumpFile( File reportsDir, String dumpFileName )
90 {
91 return newDumpFile( reportsDir, dumpFileName + DUMP_FILE_EXT );
92 }
93
94 private File createDumpStreamFile( File reportsDir, String dumpFileName )
95 {
96 return newDumpFile( reportsDir, dumpFileName + DUMPSTREAM_FILE_EXT );
97 }
98 }