1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.cli.logging;
20
21 import org.apache.maven.logging.ProjectBuildLogAppender;
22 import org.codehaus.plexus.logging.Logger;
23
24
25
26
27
28
29
30 public class Slf4jLogger implements Logger {
31
32 private org.slf4j.Logger logger;
33 private String projectId;
34
35 public Slf4jLogger(org.slf4j.Logger logger) {
36 this.logger = logger;
37 this.projectId = ProjectBuildLogAppender.getProjectId();
38 }
39
40 public void debug(String message) {
41 setMdc();
42 logger.debug(message);
43 }
44
45 public void debug(String message, Throwable throwable) {
46 setMdc();
47 logger.debug(message, throwable);
48 }
49
50 public boolean isDebugEnabled() {
51 return logger.isDebugEnabled();
52 }
53
54 public void info(String message) {
55 setMdc();
56 logger.info(message);
57 }
58
59 public void info(String message, Throwable throwable) {
60 setMdc();
61 logger.info(message, throwable);
62 }
63
64 public boolean isInfoEnabled() {
65 return logger.isInfoEnabled();
66 }
67
68 public void warn(String message) {
69 setMdc();
70 logger.warn(message);
71 }
72
73 public void warn(String message, Throwable throwable) {
74 setMdc();
75 logger.warn(message, throwable);
76 }
77
78 public boolean isWarnEnabled() {
79 return logger.isWarnEnabled();
80 }
81
82 public void error(String message) {
83 setMdc();
84 logger.error(message);
85 }
86
87 public void error(String message, Throwable throwable) {
88 setMdc();
89 logger.error(message, throwable);
90 }
91
92 public boolean isErrorEnabled() {
93 return logger.isErrorEnabled();
94 }
95
96 public void fatalError(String message) {
97 setMdc();
98 logger.error(message);
99 }
100
101 public void fatalError(String message, Throwable throwable) {
102 setMdc();
103 logger.error(message, throwable);
104 }
105
106 public boolean isFatalErrorEnabled() {
107 return logger.isErrorEnabled();
108 }
109
110
111
112
113 public int getThreshold() {
114 return 0;
115 }
116
117
118
119
120 public void setThreshold(int threshold) {}
121
122
123
124
125 public Logger getChildLogger(String name) {
126 return null;
127 }
128
129 public String getName() {
130 return logger.getName();
131 }
132
133 private void setMdc() {
134 if (projectId != null && ProjectBuildLogAppender.getProjectId() == null) {
135 ProjectBuildLogAppender.setProjectId(projectId);
136 }
137 }
138 }