1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.log4j.bridge;
18
19 import org.apache.log4j.spi.ErrorHandler;
20 import org.apache.logging.log4j.core.LogEvent;
21
22
23
24
25 public class ErrorHandlerAdapter implements org.apache.logging.log4j.core.ErrorHandler {
26
27 private final ErrorHandler errorHandler;
28
29 public ErrorHandlerAdapter(ErrorHandler errorHandler) {
30 this.errorHandler = errorHandler;
31 }
32
33 public ErrorHandler getHandler() {
34 return errorHandler;
35 }
36
37 @Override
38 public void error(String msg) {
39 errorHandler.error(msg);
40 }
41
42 @Override
43 public void error(String msg, Throwable t) {
44 if (t instanceof Exception) {
45 errorHandler.error(msg, (Exception) t, 0);
46 } else {
47 errorHandler.error(msg);
48 }
49 }
50
51 @Override
52 public void error(String msg, LogEvent event, Throwable t) {
53 if (t == null || t instanceof Exception) {
54 errorHandler.error(msg, (Exception) t, 0, new LogEventAdapter(event));
55 } else {
56 errorHandler.error(msg);
57 }
58 }
59 }