View | Details | Raw Unified | Return to bug 59777
Collapse All | Expand All

(-)build.xml (-1 / +37 lines)
Lines 134-139 Link Here
134
      <sourcePath path="${src.mail}" />
134
      <sourcePath path="${src.mail}" />
135
      <sourcePath path="${src.components}" />
135
      <sourcePath path="${src.components}" />
136
      <sourcePath path="${src.functions}" />
136
      <sourcePath path="${src.functions}" />
137
      <sourcePath path="${src.slf4j_logkit}" />
137
      <class location="${lib.dir}/jorphan.jar" />
138
      <class location="${lib.dir}/jorphan.jar" />
138
      <class location="${dest.jar}/ApacheJMeter_components.jar"/>
139
      <class location="${dest.jar}/ApacheJMeter_components.jar"/>
139
      <class location="${dest.jar}/ApacheJMeter_components.jar"/>
140
      <class location="${dest.jar}/ApacheJMeter_components.jar"/>
Lines 151-156 Link Here
151
      <class location="${dest.jar}/ApacheJMeter_native.jar"/>
152
      <class location="${dest.jar}/ApacheJMeter_native.jar"/>
152
      <class location="${dest.jar}/ApacheJMeter_mongodb.jar"/>
153
      <class location="${dest.jar}/ApacheJMeter_mongodb.jar"/>
153
      <class location="${dest.jar}/ApacheJMeter_tcp.jar"/>
154
      <class location="${dest.jar}/ApacheJMeter_tcp.jar"/>
155
      <class location="${dest.jar}/ApacheJMeter_slf4j_logkit.jar"/>
154
      <class location="${dest.jar.jmeter}/ApacheJMeter.jar" />
156
      <class location="${dest.jar.jmeter}/ApacheJMeter.jar" />
155
      <sourcePath path="${src.jorphan}" />
157
      <sourcePath path="${src.jorphan}" />
156
      <sourcePath path="${src.tcp}" />
158
      <sourcePath path="${src.tcp}" />
Lines 220-225 Link Here
220
  <property name="src.jms" value="src/protocol/jms"/>
222
  <property name="src.jms" value="src/protocol/jms"/>
221
  <property name="src.native" value="src/protocol/native"/>
223
  <property name="src.native" value="src/protocol/native"/>
222
  <property name="src.mongodb" value="src/protocol/mongodb"/>
224
  <property name="src.mongodb" value="src/protocol/mongodb"/>
225
  <property name="src.slf4j_logkit" value="src/slf4j-logkit"/>
223
226
224
  <!-- Where the documentation sources live -->
227
  <!-- Where the documentation sources live -->
225
  <property name="src.docs" value="xdocs"/>
228
  <property name="src.docs" value="xdocs"/>
Lines 247-252 Link Here
247
    <pathelement location="${src.jms}"/>
250
    <pathelement location="${src.jms}"/>
248
    <pathelement location="${src.native}"/>
251
    <pathelement location="${src.native}"/>
249
    <pathelement location="${src.mongodb}"/>
252
    <pathelement location="${src.mongodb}"/>
253
    <pathelement location="${src.slf4j_logkit}"/>
250
  </path>
254
  </path>
251
255
252
  <!-- Temporary build directories: where the .class live -->
256
  <!-- Temporary build directories: where the .class live -->
Lines 269-274 Link Here
269
  <property name="build.jms" value="build/protocol/jms"/>
273
  <property name="build.jms" value="build/protocol/jms"/>
270
  <property name="build.native" value="build/protocol/native"/>
274
  <property name="build.native" value="build/protocol/native"/>
271
  <property name="build.mongodb" value="build/protocol/mongodb"/>
275
  <property name="build.mongodb" value="build/protocol/mongodb"/>
276
  <property name="build.slf4j_logkit" value="build/slf4j-logkit"/>
272
  <property name="build.test" value="build/test"/>
277
  <property name="build.test" value="build/test"/>
273
  <property name="build.res" value="build/res"/>
278
  <property name="build.res" value="build/res"/>
274
  <property name="build.test-res" value="test/resources"/>
279
  <property name="build.test-res" value="test/resources"/>
Lines 505-510 Link Here
505
    <fileset dir="${lib.opt}" includes="*.jar"/>
510
    <fileset dir="${lib.opt}" includes="*.jar"/>
506
  </path>
511
  </path>
507
512
513
	
514
  <path id="slf4j_logkit_classpath">
515
    <!-- Externally produced jars -->
516
    <pathelement location="${lib.dir}/${logkit.jar}"/>
517
    <pathelement location="${lib.dir}/${slf4j-api.jar}"/>
518
  </path>
519
	
508
  <!-- Anakia classpath -->
520
  <!-- Anakia classpath -->
509
  <path id="anakia.classpath">
521
  <path id="anakia.classpath">
510
    <pathelement location="${lib.doc}/${velocity.jar}"/>
522
    <pathelement location="${lib.doc}/${velocity.jar}"/>
Lines 859-866 Link Here
859
    </javac>
871
    </javac>
860
  </target>
872
  </target>
861
873
874
  <target name="compile-slf4j_logkit" description="Compile JMeter slf4j LogKit bootstrap classes.">
875
    <mkdir dir="${build.slf4j_logkit}"/>
876
    <javac srcdir="${src.slf4j_logkit}" destdir="${build.slf4j_logkit}" optimize="${optimize}" source="${src.java.version}" debug="on" target="${target.java.version}"
877
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
878
      <include name="**/*.java"/>
879
      <classpath>
880
        <path refid="slf4j_logkit_classpath"/>
881
      </classpath>
882
    </javac>
883
  </target>
884
862
  <target name="compile"
885
  <target name="compile"
863
  depends="_message_3rdParty,compile-core,compile-components,compile-functions,compile-protocols,compile-monitor,compile-junit,compile-jms,compile-native, compile-mongodb"
886
  depends="_message_3rdParty,compile-core,compile-components,compile-functions,compile-protocols,compile-monitor,compile-junit,compile-jms,compile-native, compile-mongodb,compile-slf4j_logkit"
864
  description="Compile everything."/>
887
  description="Compile everything."/>
865
888
866
  <target name="run_gui" depends="package" description="Run the JMeter GUI off the jar files">
889
  <target name="run_gui" depends="package" description="Run the JMeter GUI off the jar files">
Lines 1147-1152 Link Here
1147
      <fileset dir="${src.mongodb}" includes="**/*.properties" />
1170
      <fileset dir="${src.mongodb}" includes="**/*.properties" />
1148
    </jar>
1171
    </jar>
1149
1172
1173
    <!-- slf4j-logkit -->
1174
    <!-- Ensure that build dir exists, even if slf4j-logkit has not been built -->
1175
    <mkdir dir="${build.slf4j_logkit}"/>
1176
    <jar jarfile="${dest.jar}/ApacheJMeter_slf4j_logkit.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
1177
      <zipfileset file="${resources.meta-inf}/default.notice"
1178
        fullpath="META-INF/NOTICE" />
1179
      <zipfileset file="${resources.meta-inf}/default.license"
1180
        fullpath="META-INF/LICENSE" />
1181
      <fileset dir="${build.slf4j_logkit}" includes="**/*.class" />
1182
      <fileset dir="${src.slf4j_logkit}" includes="**/*.properties" />
1183
    </jar>
1184
1150
    <jar jarfile="${lib.dir}/jorphan.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
1185
    <jar jarfile="${lib.dir}/jorphan.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
1151
      <zipfileset file="${resources.meta-inf}/default.notice"
1186
      <zipfileset file="${resources.meta-inf}/default.notice"
1152
          fullpath="META-INF/NOTICE" />
1187
          fullpath="META-INF/NOTICE" />
Lines 2001-2006 Link Here
2001
    <deployfile stem="ApacheJMeter_monitors"/>
2036
    <deployfile stem="ApacheJMeter_monitors"/>
2002
    <deployfile stem="ApacheJMeter_native"/>
2037
    <deployfile stem="ApacheJMeter_native"/>
2003
    <deployfile stem="ApacheJMeter_tcp"/>
2038
    <deployfile stem="ApacheJMeter_tcp"/>
2039
    <deployfile stem="ApacheJMeter_slf4j_logkit"/>
2004
  </target>
2040
  </target>
2005
2041
2006
  <!--
2042
  <!--
(-)eclipse.classpath (+1 lines)
Lines 42-47 Link Here
42
	<classpathentry kind="src" output="build/protocol/mongodb" path="src/protocol/mongodb"/>
42
	<classpathentry kind="src" output="build/protocol/mongodb" path="src/protocol/mongodb"/>
43
	<classpathentry kind="src" output="build/protocol/native" path="src/protocol/native"/>
43
	<classpathentry kind="src" output="build/protocol/native" path="src/protocol/native"/>
44
	<classpathentry kind="src" output="build/protocol/tcp" path="src/protocol/tcp"/>
44
	<classpathentry kind="src" output="build/protocol/tcp" path="src/protocol/tcp"/>
45
	<classpathentry kind="src" output="build/slf4j-logkit" path="src/slf4j-logkit"/>
45
	<classpathentry kind="src" output="build/test" path="test/src"/>
46
	<classpathentry kind="src" output="build/test" path="test/src"/>
46
	<classpathentry kind="lib" path="lib/accessors-smart-1.1.jar"/>
47
	<classpathentry kind="lib" path="lib/accessors-smart-1.1.jar"/>
47
	<classpathentry kind="lib" path="lib/asm-5.1.jar"/>
48
	<classpathentry kind="lib" path="lib/asm-5.1.jar"/>
(-)res/maven/ApacheJMeter_core.pom (-1 / +6 lines)
Lines 35-40 Link Here
35
            <artifactId>jorphan</artifactId>
35
            <artifactId>jorphan</artifactId>
36
            <version>@MAVEN.DEPLOY.VERSION@</version>
36
            <version>@MAVEN.DEPLOY.VERSION@</version>
37
        </dependency>
37
        </dependency>
38
        <dependency>
39
            <groupId>org.apache.jmeter</groupId>
40
            <artifactId>ApacheJMeter_slf4j_logkit</artifactId>
41
            <version>@MAVEN.DEPLOY.VERSION@</version>
42
        </dependency>
38
    </dependencies>
43
    </dependencies>
39
44
40
</project>
45
</project>
(-)res/maven/ApacheJMeter_slf4j_logkit.pom (+70 lines)
Line 0 Link Here
1
<!--
2
Licensed to the Apache Software Foundation (ASF) under one
3
or more contributor license agreements.  See the NOTICE file
4
distributed with this work for additional information
5
regarding copyright ownership.  The ASF licenses this file
6
to you under the Apache License, Version 2.0 (the
7
"License"); you may not use this file except in compliance
8
with the License.  You may obtain a copy of the License at
9
10
  http://www.apache.org/licenses/LICENSE-2.0
11
12
Unless required by applicable law or agreed to in writing,
13
software distributed under the License is distributed on an
14
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
KIND, either express or implied.  See the License for the
16
specific language governing permissions and limitations
17
under the License.
18
-->
19
20
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
21
    <modelVersion>4.0.0</modelVersion>
22
    <groupId>org.apache.jmeter</groupId>
23
    <artifactId>ApacheJMeter_slf4j_logkit</artifactId>
24
    <version>@MAVEN.DEPLOY.VERSION@</version>
25
    <name>Apache JMeter SLF4J Logkit</name>
26
    <!-- Parent poms have to be packaged as pom, not jar -->
27
    <packaging>pom</packaging>
28
29
    <description>Apache JMeter SLF4K Logkit is open source software, it is a slf4j binding for logkit used by Apache JMeter
30
    </description>
31
    <url>http://jmeter.apache.org/</url>
32
    <inceptionYear>2016</inceptionYear>
33
    <licenses>
34
        <license>
35
            <name>Apache 2</name>
36
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
37
            <distribution>repo</distribution>
38
            <comments>A business-friendly OSS license</comments>
39
        </license>
40
    </licenses>
41
    <issueManagement>
42
        <system>bugzilla</system>
43
        <url>https://bz.apache.org/bugzilla/describecomponents.cgi?product=JMeter</url>
44
    </issueManagement>
45
    <scm>
46
        <connection>http://svn.apache.org/repos/asf/jmeter/trunk/</connection>
47
        <developerConnection>https://svn.apache.org/repos/asf/jmeter/trunk/</developerConnection>
48
        <url>http://svn.apache.org/viewvc/jmeter/trunk/</url>
49
    </scm>
50
51
52
    <properties>
53
      <!-- these must agree with the definitions in build.properties -->
54
      <logkit.version>2.0</logkit.version>
55
      <slf4j-api.version>1.7.13</slf4j-api.version>
56
    </properties>
57
58
    <dependencies>
59
      <dependency>
60
        <groupId>logkit</groupId>
61
        <artifactId>logkit</artifactId>
62
        <version>${logkit.version}</version>
63
      </dependency>
64
      <dependency>
65
        <groupId>org.slf4j</groupId>
66
        <artifactId>slf4j-api</artifactId>
67
        <version>${slf4j-api.version}</version>
68
      </dependency>
69
    </dependencies>
70
</project>
(-)src/slf4j-logkit/org/apache/jmeter/logging/LogkitLoggerAdapter.java (+341 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.logging;
20
21
import java.io.Serializable;
22
23
import org.apache.log.Logger;
24
import org.apache.log.Priority;
25
import org.slf4j.helpers.FormattingTuple;
26
import org.slf4j.helpers.MarkerIgnoringBase;
27
import org.slf4j.helpers.MessageFormatter;
28
29
/**
30
 * Logkit adapter for slf4j 
31
 * @since 3.0
32
 */
33
public class LogkitLoggerAdapter extends MarkerIgnoringBase implements Serializable {
34
35
    final transient Logger logger;
36
37
    private static final long serialVersionUID = -122848886791823355L;
38
39
    /**
40
     * @deprecated Only for use by JUnit
41
     */
42
    @Deprecated // only for Unit test usage
43
    public LogkitLoggerAdapter() {
44
        super();
45
        this.logger = null;
46
    }
47
    
48
    LogkitLoggerAdapter(org.apache.log.Logger logkitLogger) {
49
        this.logger = logkitLogger;
50
    }
51
52
    /* (non-Javadoc)
53
     * @see org.slf4j.Logger#debug(java.lang.String)
54
     */
55
    @Override
56
    public void debug(String msg) {
57
        logger.debug(msg);
58
    }
59
60
    /* (non-Javadoc)
61
     * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object)
62
     */
63
    @Override
64
    public void debug(String format, Object arg) {
65
        if (logger.isDebugEnabled()) {
66
            FormattingTuple ft = MessageFormatter.format(format, arg);
67
            logger.log(Priority.DEBUG, ft.getMessage(), ft.getThrowable());
68
        }
69
    }
70
71
    /* (non-Javadoc)
72
     * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object[])
73
     */
74
    @Override
75
    public void debug(String format, Object... args) {
76
        if (logger.isDebugEnabled()) {
77
            FormattingTuple ft = MessageFormatter.format(format, args);
78
            logger.log(Priority.DEBUG, ft.getMessage(), ft.getThrowable());
79
        }
80
    }
81
82
    /* (non-Javadoc)
83
     * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Throwable)
84
     */
85
    @Override
86
    public void debug(String msg, Throwable throwable) {
87
        if (logger.isDebugEnabled()) {
88
            logger.log(Priority.DEBUG, msg, throwable);
89
        }
90
    }
91
92
    /* (non-Javadoc)
93
     * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object, java.lang.Object)
94
     */
95
    @Override
96
    public void debug(String format, Object arg1, Object arg2) {
97
        if (logger.isDebugEnabled()) {
98
            FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
99
            logger.log(Priority.DEBUG, ft.getMessage(), ft.getThrowable());
100
        }
101
    }
102
103
    /* (non-Javadoc)
104
     * @see org.slf4j.Logger#error(java.lang.String)
105
     */
106
    @Override
107
    public void error(String message) {
108
        if (logger.isErrorEnabled()) {
109
            logger.log(Priority.ERROR, message);
110
        }
111
    }
112
113
    /* (non-Javadoc)
114
     * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object)
115
     */
116
    @Override
117
    public void error(String format, Object arg) {
118
        if (logger.isErrorEnabled()) {
119
            FormattingTuple ft = MessageFormatter.format(format, arg);
120
            logger.log(Priority.ERROR, ft.getMessage(), ft.getThrowable());
121
        }
122
    }
123
124
    /* (non-Javadoc)
125
     * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object[])
126
     */
127
    @Override
128
    public void error(String format, Object... args) {
129
        if (logger.isErrorEnabled()) {
130
            FormattingTuple ft = MessageFormatter.format(format, args);
131
            logger.log(Priority.ERROR, ft.getMessage(), ft.getThrowable());
132
        }
133
    }
134
135
    /* (non-Javadoc)
136
     * @see org.slf4j.Logger#error(java.lang.String, java.lang.Throwable)
137
     */
138
    @Override
139
    public void error(String message, Throwable throwable) {
140
        if (logger.isErrorEnabled()) {
141
            logger.log(Priority.ERROR, message, throwable);
142
        }
143
    }
144
145
    /* (non-Javadoc)
146
     * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object, java.lang.Object)
147
     */
148
    @Override
149
    public void error(String format, Object arg1, Object arg2) {
150
        if (logger.isErrorEnabled()) {
151
            FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
152
            logger.log(Priority.ERROR, ft.getMessage(), ft.getThrowable());
153
        }
154
    }
155
156
    /* (non-Javadoc)
157
     * @see org.slf4j.Logger#info(java.lang.String)
158
     */
159
    @Override
160
    public void info(String message) {
161
        if (logger.isInfoEnabled()) {
162
            logger.log(Priority.INFO, message);
163
        }
164
    }
165
166
    /* (non-Javadoc)
167
     * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object)
168
     */
169
    @Override
170
    public void info(String format, Object arg1) {
171
        if (logger.isInfoEnabled()) {
172
            FormattingTuple ft = MessageFormatter.format(format, arg1);
173
            logger.log(Priority.INFO, ft.getMessage(), ft.getThrowable());
174
        }
175
    }
176
177
    /* (non-Javadoc)
178
     * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object[])
179
     */
180
    @Override
181
    public void info(String format, Object... args) {
182
        if (logger.isInfoEnabled()) {
183
            FormattingTuple ft = MessageFormatter.format(format, args);
184
            logger.log(Priority.INFO, ft.getMessage(), ft.getThrowable());
185
        }
186
    }
187
188
    /* (non-Javadoc)
189
     * @see org.slf4j.Logger#info(java.lang.String, java.lang.Throwable)
190
     */
191
    @Override
192
    public void info(String message, Throwable throwable) {
193
        if (logger.isInfoEnabled()) {
194
            logger.log(Priority.INFO, message, throwable);
195
        }
196
    }
197
198
    /* (non-Javadoc)
199
     * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object, java.lang.Object)
200
     */
201
    @Override
202
    public void info(String format, Object arg1, Object arg2) {
203
        if (logger.isInfoEnabled()) {
204
            FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
205
            logger.log(Priority.INFO, ft.getMessage(), ft.getThrowable());
206
        }
207
    }
208
209
    /* (non-Javadoc)
210
     * @see org.slf4j.Logger#isDebugEnabled()
211
     */
212
    @Override
213
    public boolean isDebugEnabled() {
214
        return logger.isDebugEnabled();
215
    }
216
217
    /* (non-Javadoc)
218
     * @see org.slf4j.Logger#isErrorEnabled()
219
     */
220
    @Override
221
    public boolean isErrorEnabled() {
222
        return logger.isErrorEnabled();
223
    }
224
225
    /* (non-Javadoc)
226
     * @see org.slf4j.Logger#isInfoEnabled()
227
     */
228
    @Override
229
    public boolean isInfoEnabled() {
230
        return logger.isInfoEnabled();
231
    }
232
233
    /* (non-Javadoc)
234
     * @see org.slf4j.Logger#isTraceEnabled()
235
     */
236
    @Override
237
    public boolean isTraceEnabled() {
238
        return logger.isDebugEnabled();
239
    }
240
241
    /* (non-Javadoc)
242
     * @see org.slf4j.Logger#isWarnEnabled()
243
     */
244
    @Override
245
    public boolean isWarnEnabled() {
246
        return logger.isWarnEnabled();
247
    }
248
249
    /* (non-Javadoc)
250
     * @see org.slf4j.Logger#warn(java.lang.String)
251
     */
252
    @Override
253
    public void warn(String message) {
254
        if (logger.isWarnEnabled()) {
255
            logger.log(Priority.WARN, message);
256
        }
257
    }
258
259
    /* (non-Javadoc)
260
     * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object)
261
     */
262
    @Override
263
    public void warn(String format, Object arg) {
264
        if (logger.isWarnEnabled()) {
265
            FormattingTuple ft = MessageFormatter.format(format, arg);
266
            logger.log(Priority.WARN, ft.getMessage(), ft.getThrowable());
267
        }
268
    }
269
270
    /* (non-Javadoc)
271
     * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object[])
272
     */
273
    @Override
274
    public void warn(String format, Object... args) {
275
        if (logger.isWarnEnabled()) {
276
            FormattingTuple ft = MessageFormatter.format(format, args);
277
            logger.log(Priority.WARN, ft.getMessage(), ft.getThrowable());
278
        }
279
    }
280
281
    /* (non-Javadoc)
282
     * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Throwable)
283
     */
284
    @Override
285
    public void warn(String message, Throwable throwable) {
286
        if (logger.isWarnEnabled()) {
287
            logger.log(Priority.WARN, message, throwable);
288
        }
289
    }
290
291
    /* (non-Javadoc)
292
     * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object, java.lang.Object)
293
     */
294
    @Override
295
    public void warn(String format, Object arg1, Object arg2) {
296
        if (logger.isWarnEnabled()) {
297
            FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
298
            logger.log(Priority.WARN, ft.getMessage(), ft.getThrowable());
299
        }
300
    }
301
302
    /* (non-Javadoc)
303
     * @see org.slf4j.Logger#trace(java.lang.String)
304
     */
305
    @Override
306
    public void trace(String message) {
307
        debug(message);
308
    }
309
310
    /* (non-Javadoc)
311
     * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object)
312
     */
313
    @Override
314
    public void trace(String format, Object arg) {
315
        debug(format, arg);
316
    }
317
318
    /* (non-Javadoc)
319
     * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object[])
320
     */
321
    @Override
322
    public void trace(String format, Object... args) {
323
        debug(format, args);
324
    }
325
326
    /* (non-Javadoc)
327
     * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Throwable)
328
     */
329
    @Override
330
    public void trace(String message, Throwable throwable) {
331
        debug(message, throwable);
332
    }
333
334
    /* (non-Javadoc)
335
     * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object, java.lang.Object)
336
     */
337
    @Override
338
    public void trace(String format, Object arg1, Object arg2) {
339
        debug(format, arg1, arg2);
340
    }
341
}
(-)src/slf4j-logkit/org/apache/jmeter/logging/LogkitLoggerFactory.java (+69 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.logging;
20
21
import java.util.HashMap;
22
import java.util.Map;
23
24
import org.apache.log.Hierarchy;
25
import org.slf4j.ILoggerFactory;
26
import org.slf4j.Logger;
27
28
/**
29
 * Implementation of {@link ILoggerFactory} for Logkit
30
 * @since 3.0
31
 */
32
public class LogkitLoggerFactory implements ILoggerFactory {
33
    // key: name (String), value: a Log4jLogger;
34
    private final Map<String, Logger> loggerMap;
35
36
    /**
37
     * 
38
     */
39
    public LogkitLoggerFactory() {
40
        loggerMap = new HashMap<>();
41
    }
42
43
    /**
44
     * 
45
     * @see org.slf4j.ILoggerFactory#getLogger(java.lang.String)
46
     */
47
    @Override
48
    public Logger getLogger(String name) {
49
        Logger slf4jLogger = null;
50
        if(name == null) {
51
            name = Logger.ROOT_LOGGER_NAME;
52
        }
53
        // protect against concurrent access of loggerMap
54
        synchronized (this) {
55
            slf4jLogger = loggerMap.get(name);
56
            if (slf4jLogger == null) {
57
                org.apache.log.Logger logkitLogger;
58
                if (name.equalsIgnoreCase(Logger.ROOT_LOGGER_NAME)) {
59
                    logkitLogger = Hierarchy.getDefaultHierarchy().getRootLogger();
60
                } else {
61
                    logkitLogger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
62
                }
63
                slf4jLogger = new LogkitLoggerAdapter(logkitLogger);
64
                loggerMap.put(name, slf4jLogger);
65
            }
66
        }
67
        return slf4jLogger;
68
    }
69
}
(-)src/slf4j-logkit/org/slf4j/impl/StaticLoggerBinder.java (+78 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.slf4j.impl;
20
21
import org.apache.jmeter.logging.LogkitLoggerFactory;
22
import org.slf4j.ILoggerFactory;
23
import org.slf4j.LoggerFactory;
24
import org.slf4j.spi.LoggerFactoryBinder;
25
26
/**
27
 * The binding of {@link LoggerFactory} class with an actual instance of
28
 * {@link ILoggerFactory} is performed using information returned by this class.
29
 * 
30
 * @since 3.0
31
 */
32
public class StaticLoggerBinder implements LoggerFactoryBinder {
33
34
    /**
35
     * The unique instance of this class.
36
     * 
37
     */
38
    private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
39
40
    /**
41
     * Return the singleton of this class.
42
     * 
43
     * @return the StaticLoggerBinder singleton
44
     */
45
    public static final StaticLoggerBinder getSingleton() {
46
        return SINGLETON;
47
    }
48
49
    /**
50
     * Declare the version of the SLF4J API this implementation is compiled
51
     * against. The value of this field is usually modified with each release.
52
     */
53
    // to avoid constant folding by the compiler, this field must *not* be final
54
    public static String REQUESTED_API_VERSION = "1.7"; // !final
55
56
    private static final String loggerFactoryClassStr = LogkitLoggerFactory.class
57
            .getName();
58
59
    /**
60
     * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
61
     * method should always be the same object
62
     */
63
    private final ILoggerFactory loggerFactory;
64
65
    private StaticLoggerBinder() {
66
        loggerFactory = new LogkitLoggerFactory();
67
    }
68
69
    @Override
70
    public ILoggerFactory getLoggerFactory() {
71
        return loggerFactory;
72
    }
73
74
    @Override
75
    public String getLoggerFactoryClassStr() {
76
        return loggerFactoryClassStr;
77
    }
78
}

Return to bug 59777