1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.cling.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 final org.slf4j.Logger logger;
33 private final String projectId;
34
35 public Slf4jLogger(org.slf4j.Logger logger) {
36 this.logger = logger;
37 this.projectId = ProjectBuildLogAppender.getProjectId();
38 }
39
40 @Override
41 public void debug(String message) {
42 setMdc();
43 logger.debug(message);
44 }
45
46 @Override
47 public void debug(String message, Throwable throwable) {
48 setMdc();
49 logger.debug(message, throwable);
50 }
51
52 @Override
53 public boolean isDebugEnabled() {
54 return logger.isDebugEnabled();
55 }
56
57 @Override
58 public void info(String message) {
59 setMdc();
60 logger.info(message);
61 }
62
63 @Override
64 public void info(String message, Throwable throwable) {
65 setMdc();
66 logger.info(message, throwable);
67 }
68
69 @Override
70 public boolean isInfoEnabled() {
71 return logger.isInfoEnabled();
72 }
73
74 @Override
75 public void warn(String message) {
76 setMdc();
77 logger.warn(message);
78 }
79
80 @Override
81 public void warn(String message, Throwable throwable) {
82 setMdc();
83 logger.warn(message, throwable);
84 }
85
86 @Override
87 public boolean isWarnEnabled() {
88 return logger.isWarnEnabled();
89 }
90
91 @Override
92 public void error(String message) {
93 setMdc();
94 logger.error(message);
95 }
96
97 @Override
98 public void error(String message, Throwable throwable) {
99 setMdc();
100 logger.error(message, throwable);
101 }
102
103 @Override
104 public boolean isErrorEnabled() {
105 return logger.isErrorEnabled();
106 }
107
108 @Override
109 public void fatalError(String message) {
110 setMdc();
111 logger.error(message);
112 }
113
114 @Override
115 public void fatalError(String message, Throwable throwable) {
116 setMdc();
117 logger.error(message, throwable);
118 }
119
120 @Override
121 public boolean isFatalErrorEnabled() {
122 return logger.isErrorEnabled();
123 }
124
125
126
127
128 @Override
129 public int getThreshold() {
130 return 0;
131 }
132
133
134
135
136 @Override
137 public void setThreshold(int threshold) {}
138
139
140
141
142 @Override
143 public Logger getChildLogger(String name) {
144 return null;
145 }
146
147 @Override
148 public String getName() {
149 return logger.getName();
150 }
151
152 private void setMdc() {
153 if (projectId != null && ProjectBuildLogAppender.getProjectId() == null) {
154 ProjectBuildLogAppender.setProjectId(projectId);
155 }
156 }
157 }