1 package be
.nikiroo
.utils
;
4 * A handler when a trace message is sent or when a recoverable exception was
5 * caught by the program.
9 public class TraceHandler
{
10 private boolean showErrors
;
11 private boolean showTraces
;
12 private boolean showErrorDetails
;
15 * Create a default {@link TraceHandler} that will print errors on stderr
16 * (without details) and no traces.
18 public TraceHandler() {
19 this(true, false, false);
23 * Create a default {@link TraceHandler}.
26 * show errors on stderr
27 * @param showErrorDetails
28 * show more details when printing errors
30 * show traces on stdout
32 public TraceHandler(boolean showErrors
, boolean showErrorDetails
,
34 this.showErrors
= showErrors
;
35 this.showErrorDetails
= showErrorDetails
;
36 this.showTraces
= showTraces
;
40 * An exception happened, log it.
45 public void error(Exception e
) {
47 if (showErrorDetails
) {
50 error(e
.getMessage());
56 * An error happened, log it.
61 public void error(String message
) {
63 System
.err
.println(message
);
68 * A trace happened, show it.
70 * Will only be effective if {@link TraceHandler#isShowTraces()} is true.
75 public void trace(String message
) {
77 System
.out
.println(message
);