1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.util.internal.logging;
17
18
19 import org.apache.logging.log4j.Level;
20 import org.apache.logging.log4j.Logger;
21 import org.apache.logging.log4j.spi.ExtendedLogger;
22 import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;
23
24 class Log4J2Logger extends ExtendedLoggerWrapper implements InternalLogger {
25
26 private static final long serialVersionUID = 5485418394879791397L;
27
28 Log4J2Logger(Logger logger) {
29 super((ExtendedLogger) logger, logger.getName(), logger.getMessageFactory());
30 }
31
32 @Override
33 public String name() {
34 return getName();
35 }
36
37 @Override
38 public boolean isEnabled(InternalLogLevel level) {
39 return isEnabled(toLevel(level));
40 }
41
42 @Override
43 public void log(InternalLogLevel level, String msg) {
44 log(toLevel(level), msg);
45 }
46
47 @Override
48 public void log(InternalLogLevel level, String format, Object arg) {
49 log(toLevel(level), format, arg);
50 }
51
52 @Override
53 public void log(InternalLogLevel level, String format, Object argA, Object argB) {
54 log(toLevel(level), format, argA, argB);
55 }
56
57 @Override
58 public void log(InternalLogLevel level, String format, Object... arguments) {
59 log(toLevel(level), format, arguments);
60 }
61
62 @Override
63 public void log(InternalLogLevel level, String msg, Throwable t) {
64 log(toLevel(level), msg, t);
65 }
66
67 protected Level toLevel(InternalLogLevel level) {
68 switch (level) {
69 case INFO:
70 return Level.INFO;
71 case DEBUG:
72 return Level.DEBUG;
73 case WARN:
74 return Level.WARN;
75 case ERROR:
76 return Level.ERROR;
77 case TRACE:
78 return Level.TRACE;
79 default:
80 throw new Error();
81 }
82 }
83 }