Merge tag 'upstream/1.7.14'
Upstream version 1.7.14
Emmanuel Bourg
7 years ago
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>integration</artifactId> |
4 | 4 | <parent> |
5 | 5 | <groupId>org.slf4j</groupId> |
6 | 6 | <artifactId>slf4j-parent</artifactId> |
7 | <version>1.7.13</version> | |
7 | <version>1.7.14</version> | |
8 | 8 | </parent> |
9 | 9 | |
10 | 10 | <modelVersion>4.0.0</modelVersion> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>jul-to-slf4j</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 |
16 | 16 | package org.apache.log4j; |
17 | 17 | |
18 | 18 | import org.apache.log4j.spi.LoggerFactory; |
19 | import org.slf4j.helpers.Util; | |
20 | 19 | |
21 | 20 | import java.util.concurrent.ConcurrentHashMap; |
22 | 21 | import java.util.concurrent.ConcurrentMap; |
34 | 33 | |
35 | 34 | // String, Logger |
36 | 35 | private static ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<String, Logger>(); |
37 | ||
38 | private static final String LOG4J_DELEGATION_LOOP_URL = "http://www.slf4j.org/codes.html#log4jDelegationLoop"; | |
39 | ||
40 | // check for delegation loops | |
41 | static { | |
42 | try { | |
43 | Class.forName("org.slf4j.impl.Log4jLoggerFactory"); | |
44 | String part1 = "Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. "; | |
45 | String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL + " for more details."; | |
46 | ||
47 | Util.report(part1); | |
48 | Util.report(part2); | |
49 | throw new IllegalStateException(part1 + part2); | |
50 | } catch (ClassNotFoundException e) { | |
51 | // this is the good case | |
52 | } | |
53 | } | |
54 | 36 | |
55 | 37 | public static Logger getLogger(String name) { |
56 | 38 | org.apache.log4j.Logger instance = log4jLoggers.get(name); |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>osgi-over-slf4j</artifactId> |
13 | 13 | |
14 | <packaging>bundle</packaging> | |
14 | <packaging>jar</packaging> | |
15 | 15 | <name>OSGi LogService implemented over SLF4J</name> |
16 | 16 | |
17 | 17 | <url>http://www.slf4j.org</url> |
40 | 40 | <scope>provided</scope> |
41 | 41 | </dependency> |
42 | 42 | </dependencies> |
43 | <build> | |
44 | <plugins> | |
45 | <plugin> | |
46 | <groupId>org.apache.felix</groupId> | |
47 | <artifactId>maven-bundle-plugin</artifactId> | |
48 | <version>2.3.7</version> | |
49 | <extensions>true</extensions> | |
50 | <configuration> | |
51 | <instructions> | |
52 | <Export-Package>org.osgi.service.log</Export-Package> | |
53 | <Bundle-Activator>org.slf4j.osgi.logservice.impl.Activator</Bundle-Activator> | |
54 | </instructions> | |
55 | </configuration> | |
56 | </plugin> | |
57 | </plugins> | |
58 | </build> | |
59 | 43 | </project> |
0 | Implementation-Title: osgi-over-slf4j | |
1 | Bundle-ManifestVersion: 2 | |
2 | Bundle-SymbolicName: org.slf4j.osgi-over-slf4j | |
3 | Bundle-Name: OSGi LogService implemented over SLF4J | |
4 | Bundle-RequiredExecutionEnvironment: J2SE-1.5 | |
5 | Bundle-Activator: org.slf4j.osgi.logservice.impl.Activator | |
6 | Bundle-Category: osgi | |
7 | Import-Package: org.osgi.framework;version="[1.5,2)",org.osgi.service.log;version="[1.3,2)",org.slf4j;version=${parsedVersion.osgiVersion} |
5 | 5 | |
6 | 6 | <groupId>org.slf4j</groupId> |
7 | 7 | <artifactId>slf4j-parent</artifactId> |
8 | <version>1.7.13</version> | |
8 | <version>1.7.14</version> | |
9 | 9 | |
10 | 10 | <packaging>pom</packaging> |
11 | 11 | <name>SLF4J</name> |
406 | 406 | |
407 | 407 | <distributionManagement> |
408 | 408 | <site> |
409 | <id>pixie</id> | |
410 | <url>scp://pixie.qos.ch/var/www/www.slf4j.org/htdocs/</url> | |
409 | <id>tao</id> | |
410 | <url>scp://tao.qos.ch/var/www/www.slf4j.org/htdocs/</url> | |
411 | 411 | </site> |
412 | 412 | |
413 | 413 | <repository> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-android</artifactId> |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | * Declare the version of the SLF4J API this implementation is compiled against. | |
55 | * The value of this field is usually modified with each release. | |
54 | * Declare the version of the SLF4J API this implementation is compiled against. | |
55 | * The value of this field is modified with each major release. | |
56 | 56 | */ |
57 | 57 | // to avoid constant folding by the compiler, this field must *not* be final |
58 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final | |
58 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final | |
59 | ||
59 | 60 | |
60 | 61 | |
61 | 62 | private static final String loggerFactoryClassStr = AndroidLoggerFactory.class.getName(); |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | * Return the singleton of this class. | |
48 | * | |
49 | * @return the StaticMDCBinder singleton | |
50 | * @since 1.7.14 | |
51 | */ | |
52 | public static final StaticMDCBinder getSingleton() { | |
53 | return SINGLETON; | |
54 | } | |
55 | /** | |
47 | 56 | * Currently this method always returns an instance of |
48 | 57 | * {@link NOPMDCAdapter}. |
49 | 58 | */ |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | * Return the singleton of this class. | |
53 | * | |
54 | * @return the StaticMarkerBinder singleton | |
55 | * @since 1.7.14 | |
56 | */ | |
57 | public static StaticMarkerBinder getSingleton() { | |
58 | return SINGLETON; | |
59 | } | |
60 | ||
61 | /** | |
52 | 62 | * Currently this method always returns an instance of |
53 | 63 | * {@link BasicMarkerFactory}. |
54 | 64 | */ |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-api</artifactId> |
83 | 83 | |
84 | 84 | // Support for detecting mismatched logger names. |
85 | 85 | static final String DETECT_LOGGER_NAME_MISMATCH_PROPERTY = "slf4j.detectLoggerNameMismatch"; |
86 | static final String JAVA_VENDOR_PROPERTY = "java.vendor.url"; | |
87 | ||
86 | 88 | static boolean DETECT_LOGGER_NAME_MISMATCH = Util.safeGetBooleanSystemProperty(DETECT_LOGGER_NAME_MISMATCH_PROPERTY); |
87 | 89 | |
88 | 90 | /** |
221 | 223 | // the class itself. |
222 | 224 | private static String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class"; |
223 | 225 | |
224 | private static Set<URL> findPossibleStaticLoggerBinderPathSet() { | |
226 | static Set<URL> findPossibleStaticLoggerBinderPathSet() { | |
225 | 227 | // use Set instead of list in order to deal with bug #138 |
226 | 228 | // LinkedHashSet appropriate here because it preserves insertion order during iteration |
227 | 229 | Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<URL>(); |
253 | 255 | * |
254 | 256 | */ |
255 | 257 | private static void reportMultipleBindingAmbiguity(Set<URL> staticLoggerBinderPathSet) { |
258 | if(isAndroid()) { | |
259 | // skip check under android, see also http://jira.qos.ch/browse/SLF4J-328 | |
260 | return; | |
261 | } | |
262 | ||
256 | 263 | if (isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) { |
257 | 264 | Util.report("Class path contains multiple SLF4J bindings."); |
258 | 265 | for (URL path : staticLoggerBinderPathSet) { |
260 | 267 | } |
261 | 268 | Util.report("See " + MULTIPLE_BINDINGS_URL + " for an explanation."); |
262 | 269 | } |
270 | } | |
271 | ||
272 | private static boolean isAndroid() { | |
273 | String vendor = Util.safeGetSystemProperty(JAVA_VENDOR_PROPERTY); | |
274 | if(vendor == null) | |
275 | return false; | |
276 | return vendor.toLowerCase().contains("android"); | |
263 | 277 | } |
264 | 278 | |
265 | 279 | private static void reportActualBinding(Set<URL> staticLoggerBinderPathSet) { |
323 | 337 | */ |
324 | 338 | public static ILoggerFactory getILoggerFactory() { |
325 | 339 | if (INITIALIZATION_STATE == UNINITIALIZED) { |
326 | INITIALIZATION_STATE = ONGOING_INITIALIZATION; | |
327 | performInitialization(); | |
340 | synchronized (LoggerFactory.class) { | |
341 | if (INITIALIZATION_STATE == UNINITIALIZED) { | |
342 | INITIALIZATION_STATE = ONGOING_INITIALIZATION; | |
343 | performInitialization(); | |
344 | } | |
345 | } | |
328 | 346 | } |
329 | 347 | switch (INITIALIZATION_STATE) { |
330 | 348 | case SUCCESSFUL_INITIALIZATION: |
84 | 84 | private MDC() { |
85 | 85 | } |
86 | 86 | |
87 | /** | |
88 | * As of SLF4J version 1.7.14, StaticMDCBinder classes shipping in various bindings | |
89 | * come with a getSingleton() method. Previously only a public field called SINGLETON | |
90 | * was available. | |
91 | * | |
92 | * @return MDCAdapter | |
93 | * @throws NoClassDefFoundError in case no binding is available | |
94 | * @since 1.7.14 | |
95 | */ | |
96 | private static MDCAdapter bwCompatibleGetMDCAdapterFromBinder() throws NoClassDefFoundError { | |
97 | try { | |
98 | return StaticMDCBinder.getSingleton().getMDCA(); | |
99 | } catch (NoSuchMethodError nsme) { | |
100 | // binding is probably a version of SLF4J older than 1.7.14 | |
101 | return StaticMDCBinder.SINGLETON.getMDCA(); | |
102 | } | |
103 | } | |
104 | ||
87 | 105 | static { |
88 | 106 | try { |
89 | mdcAdapter = StaticMDCBinder.SINGLETON.getMDCA(); | |
107 | mdcAdapter = bwCompatibleGetMDCAdapterFromBinder(); | |
90 | 108 | } catch (NoClassDefFoundError ncde) { |
91 | 109 | mdcAdapter = new NOPMDCAdapter(); |
92 | 110 | String msg = ncde.getMessage(); |
41 | 41 | * @author Ceki Gülcü |
42 | 42 | */ |
43 | 43 | public class MarkerFactory { |
44 | static IMarkerFactory markerFactory; | |
44 | static IMarkerFactory MARKER_FACTORY; | |
45 | 45 | |
46 | 46 | private MarkerFactory() { |
47 | 47 | } |
48 | 48 | |
49 | /** | |
50 | * As of SLF4J version 1.7.14, StaticMarkerBinder classes shipping in various bindings | |
51 | * come with a getSingleton() method. Previously only a public field called SINGLETON | |
52 | * was available. | |
53 | * | |
54 | * @return IMarkerFactory | |
55 | * @throws NoClassDefFoundError in case no binding is available | |
56 | * @since 1.7.14 | |
57 | */ | |
58 | private static IMarkerFactory bwCompatibleGetMarkerFactoryFromBinder() throws NoClassDefFoundError { | |
59 | try { | |
60 | return StaticMarkerBinder.getSingleton().getMarkerFactory(); | |
61 | } catch (NoSuchMethodError nsme) { | |
62 | // binding is probably a version of SLF4J older than 1.7.14 | |
63 | return StaticMarkerBinder.SINGLETON.getMarkerFactory(); | |
64 | } | |
65 | } | |
66 | ||
67 | // this is where the binding happens | |
49 | 68 | static { |
50 | 69 | try { |
51 | markerFactory = StaticMarkerBinder.SINGLETON.getMarkerFactory(); | |
70 | MARKER_FACTORY = bwCompatibleGetMarkerFactoryFromBinder(); | |
52 | 71 | } catch (NoClassDefFoundError e) { |
53 | markerFactory = new BasicMarkerFactory(); | |
54 | ||
72 | MARKER_FACTORY = new BasicMarkerFactory(); | |
55 | 73 | } catch (Exception e) { |
56 | 74 | // we should never get here |
57 | 75 | Util.report("Unexpected failure while binding MarkerFactory", e); |
67 | 85 | * @return marker |
68 | 86 | */ |
69 | 87 | public static Marker getMarker(String name) { |
70 | return markerFactory.getMarker(name); | |
88 | return MARKER_FACTORY.getMarker(name); | |
71 | 89 | } |
72 | 90 | |
73 | 91 | /** |
78 | 96 | * @since 1.5.1 |
79 | 97 | */ |
80 | 98 | public static Marker getDetachedMarker(String name) { |
81 | return markerFactory.getDetachedMarker(name); | |
99 | return MARKER_FACTORY.getDetachedMarker(name); | |
82 | 100 | } |
83 | 101 | |
84 | 102 | /** |
90 | 108 | * @return the IMarkerFactory instance in use |
91 | 109 | */ |
92 | 110 | public static IMarkerFactory getIMarkerFactory() { |
93 | return markerFactory; | |
111 | return MARKER_FACTORY; | |
94 | 112 | } |
95 | 113 | }⏎ |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Declare the version of the SLF4J API this implementation is compiled against. |
56 | * The value of this field is usually modified with each release. | |
56 | * The value of this field is modified with each major release. | |
57 | 57 | */ |
58 | 58 | // to avoid constant folding by the compiler, this field must *not* be final |
59 | 59 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final |
41 | 41 | private StaticMDCBinder() { |
42 | 42 | throw new UnsupportedOperationException("This code should never make it into the jar"); |
43 | 43 | } |
44 | ||
45 | /** | |
46 | * Return the singleton of this class. | |
47 | * | |
48 | * @return the StaticMDCBinder singleton | |
49 | * @since 1.7.14 | |
50 | */ | |
51 | public static final StaticMDCBinder getSingleton() { | |
52 | return SINGLETON; | |
53 | } | |
44 | 54 | |
45 | 55 | /** |
46 | 56 | * Currently this method always returns an instance of |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | * Return the singleton of this class. | |
55 | * | |
56 | * @return the StaticMarkerBinder singleton | |
57 | * @since 1.7.14 | |
58 | */ | |
59 | public static StaticMarkerBinder getSingleton() { | |
60 | return SINGLETON; | |
61 | } | |
62 | ||
63 | /** | |
54 | 64 | * Currently this method always returns an instance of |
55 | 65 | * {@link BasicMarkerFactory}. |
56 | 66 | */ |
0 | package org.slf4j; | |
1 | ||
2 | import java.util.concurrent.BrokenBarrierException; | |
3 | import java.util.concurrent.CyclicBarrier; | |
4 | ||
5 | /** | |
6 | * This class demonstrates that threads accessing the STATE variable always see a consistent value. | |
7 | * | |
8 | * During ongoing initialization the observed value is either ONGOING_INITIALIZATION | |
9 | * or one of {SUCCESS, FAILURE}. | |
10 | * | |
11 | * Post initialization the observed value is always one of {SUCCESS, FAILURE}. | |
12 | * | |
13 | * See also http://jira.qos.ch/browse/SLF4J-167 | |
14 | * | |
15 | * @author ceki | |
16 | * | |
17 | */ | |
18 | public class DoubleCheckedInt { | |
19 | ||
20 | final static int THREAD_COUNT = 10 + Runtime.getRuntime().availableProcessors() * 2; | |
21 | final static int UNINITIALIZED_STATE = 0; | |
22 | final static int ONGOING_INITIALIZATION = 1; | |
23 | final static int SUCCESS = 2; | |
24 | final static int FAILURE = 3; | |
25 | final static int NUMBER_OF_STATES = FAILURE + 1; | |
26 | ||
27 | private static int STATE = UNINITIALIZED_STATE; | |
28 | ||
29 | public static int getState() { | |
30 | if (STATE == 0) { | |
31 | synchronized (DoubleCheckedInt.class) { | |
32 | if (STATE == UNINITIALIZED_STATE) { | |
33 | STATE = ONGOING_INITIALIZATION; | |
34 | long r = System.nanoTime(); | |
35 | try { | |
36 | Thread.sleep(10); | |
37 | } catch (InterruptedException e) { | |
38 | } | |
39 | if (r % 2 == 0) { | |
40 | STATE = SUCCESS; | |
41 | } else { | |
42 | STATE = FAILURE; | |
43 | } | |
44 | } | |
45 | } | |
46 | } | |
47 | return STATE; | |
48 | } | |
49 | ||
50 | static public void main(String[] args) throws InterruptedException, BrokenBarrierException { | |
51 | StateAccessingThread[] preInitializationThreads = harness(); | |
52 | check(preInitializationThreads, false); | |
53 | ||
54 | System.out.println("============"); | |
55 | StateAccessingThread[] postInitializationThreads = harness(); | |
56 | check(postInitializationThreads, true); | |
57 | } | |
58 | ||
59 | private static StateAccessingThread[] harness() throws InterruptedException, BrokenBarrierException { | |
60 | StateAccessingThread[] threads = new StateAccessingThread[THREAD_COUNT]; | |
61 | final CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1); | |
62 | for (int i = 0; i < THREAD_COUNT; i++) { | |
63 | threads[i] = new StateAccessingThread(barrier); | |
64 | threads[i].start(); | |
65 | } | |
66 | ||
67 | barrier.await(); | |
68 | for (int i = 0; i < THREAD_COUNT; i++) { | |
69 | threads[i].join(); | |
70 | } | |
71 | return threads; | |
72 | } | |
73 | ||
74 | private static void check(StateAccessingThread[] threads, boolean postInit) { | |
75 | ||
76 | int[] stateCount = getStateCount(threads); | |
77 | printStateCount(stateCount); | |
78 | ||
79 | if (stateCount[UNINITIALIZED_STATE] != 0) { | |
80 | throw new IllegalStateException("getState() should never return a zero value"); | |
81 | } | |
82 | ||
83 | if (stateCount[SUCCESS] != 0 && stateCount[FAILURE] != 0) { | |
84 | throw new IllegalStateException("getState() should return consistent values"); | |
85 | } | |
86 | ||
87 | if (postInit) { | |
88 | if (stateCount[SUCCESS] != THREAD_COUNT && stateCount[FAILURE] != THREAD_COUNT) { | |
89 | throw new IllegalStateException("getState() should return consistent values"); | |
90 | } | |
91 | } | |
92 | ||
93 | } | |
94 | ||
95 | private static void printStateCount(int[] stateCount) { | |
96 | for (int i = 0; i < NUMBER_OF_STATES; i++) { | |
97 | switch (i) { | |
98 | case UNINITIALIZED_STATE: | |
99 | System.out.println("UNINITIALIZED_STATE count: " + stateCount[i]); | |
100 | break; | |
101 | case ONGOING_INITIALIZATION: | |
102 | System.out.println("ONGOING_INITIALIZATION count: " + stateCount[i]); | |
103 | break; | |
104 | case SUCCESS: | |
105 | System.out.println("SUCCESS count: " + stateCount[i]); | |
106 | break; | |
107 | case FAILURE: | |
108 | System.out.println("FAILURE count: " + stateCount[i]); | |
109 | break; | |
110 | } | |
111 | } | |
112 | } | |
113 | ||
114 | private static int[] getStateCount(StateAccessingThread[] threads) { | |
115 | int[] valCount = new int[NUMBER_OF_STATES]; | |
116 | for (int i = 0; i < threads.length; i++) { | |
117 | int val = threads[i].state; | |
118 | valCount[val] = valCount[val] + 1; | |
119 | } | |
120 | return valCount; | |
121 | } | |
122 | ||
123 | static class StateAccessingThread extends Thread { | |
124 | public int state = -1; | |
125 | final CyclicBarrier barrier; | |
126 | ||
127 | StateAccessingThread(CyclicBarrier barrier) { | |
128 | this.barrier = barrier; | |
129 | } | |
130 | ||
131 | public void run() { | |
132 | try { | |
133 | barrier.await(); | |
134 | } catch (Exception e) { | |
135 | e.printStackTrace(); | |
136 | } | |
137 | state = DoubleCheckedInt.getState(); | |
138 | } | |
139 | }; | |
140 | } |
0 | package org.slf4j; | |
1 | ||
2 | import org.junit.Ignore; | |
3 | import org.junit.Test; | |
4 | ||
5 | public class FindStaticLoggerBinderPathsPerfTest { | |
6 | ||
7 | @Test | |
8 | @Ignore | |
9 | public void test() { | |
10 | long duration = timeFindBindingSetCall(); | |
11 | System.out.println(duration / (1000) + " microseconds"); | |
12 | ||
13 | int count = 10; | |
14 | long sum = 0; | |
15 | for (int i = 0; i < count; i++) { | |
16 | sum += timeFindBindingSetCall(); | |
17 | } | |
18 | System.out.println(sum / (count * 1000) + " microseconds in average"); | |
19 | } | |
20 | ||
21 | @Test | |
22 | public void testAsync() throws InterruptedException { | |
23 | long start = System.nanoTime(); | |
24 | FindPathSetThread thread = new FindPathSetThread(); | |
25 | thread.start(); | |
26 | long end = System.nanoTime(); | |
27 | ||
28 | long duration = end - start; | |
29 | System.out.println(duration / (1000) + " microseconds"); | |
30 | ||
31 | thread.join(); | |
32 | } | |
33 | ||
34 | long timeFindBindingSetCall() { | |
35 | long start = System.nanoTime(); | |
36 | ||
37 | LoggerFactory.findPossibleStaticLoggerBinderPathSet(); | |
38 | long end = System.nanoTime(); | |
39 | return end - start; | |
40 | ||
41 | } | |
42 | ||
43 | static class FindPathSetThread extends Thread { | |
44 | ||
45 | public void run() { | |
46 | long start = System.nanoTime(); | |
47 | LoggerFactory.findPossibleStaticLoggerBinderPathSet(); | |
48 | long end = System.nanoTime(); | |
49 | ||
50 | System.out.println("Found set in " + (end - start)/1000 + " microseconds"); | |
51 | ||
52 | } | |
53 | } | |
54 | } |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-ext</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-jcl</artifactId> |
45 | 45 | static { |
46 | 46 | try { |
47 | 47 | Class.forName("org.apache.commons.logging.impl.SLF4JLogFactory"); |
48 | String part1 = "Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. "; | |
48 | String part1 = "Detected both jcl-over-slf4j.jar AND bound slf4j-jcl.jar on the class path, preempting StackOverflowError. "; | |
49 | 49 | String part2 = "See also " + JCL_DELEGATION_LOOP_URL + " for more details."; |
50 | 50 | |
51 | 51 | Util.report(part1); |
57 | 57 | } |
58 | 58 | |
59 | 59 | // key: name (String), value: a JCLLoggerAdapter; |
60 | ConcurrentMap<String, Logger> loggerMap; | |
60 | final ConcurrentMap<String, Logger> loggerMap; | |
61 | 61 | |
62 | 62 | public JCLLoggerFactory() { |
63 | 63 | loggerMap = new ConcurrentHashMap<String, Logger>(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | * Version tag used to check compatibility. The value of this field is | |
54 | * modified with each release. | |
53 | * Declare the version of the SLF4J API this implementation is compiled against. | |
54 | * The value of this field is modified with each major release. | |
55 | 55 | */ |
56 | // to avoid constant folding by the compiler, this field must *not* be final | |
57 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final | |
56 | 58 | |
57 | // to avoid constant folding by the compiler, this field must *not* be final | |
58 | public static String REQUESTED_API_VERSION = "1.6.99"; | |
59 | ||
59 | ||
60 | 60 | // Binding specific code: |
61 | 61 | private static final String loggerFactoryClassStr = JCLLoggerFactory.class.getName(); |
62 | 62 |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | * Return the singleton of this class. | |
46 | * | |
47 | * @return the StaticMDCBinder singleton | |
48 | * @since 1.7.14 | |
49 | */ | |
50 | public static final StaticMDCBinder getSingleton() { | |
51 | return SINGLETON; | |
52 | } | |
53 | ||
54 | /** | |
45 | 55 | * Currently this method always returns an instance of |
46 | 56 | * {@link NOPMDCAdapter}. |
47 | 57 | * |
48 | 58 | * @return instance of NOPMDCAdapter |
59 | * @since 1.7.14 | |
49 | 60 | */ |
50 | 61 | public MDCAdapter getMDCA() { |
51 | 62 | return new NOPMDCAdapter(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | * Return the singleton of this class. | |
52 | * | |
53 | * @return the StaticMarkerBinder singleton | |
54 | * @since 1.7.14 | |
55 | */ | |
56 | public static StaticMarkerBinder getSingleton() { | |
57 | return SINGLETON; | |
58 | } | |
59 | ||
60 | /** | |
51 | 61 | * Currently this method always returns an instance of |
52 | 62 | * {@link BasicMarkerFactory}. |
53 | 63 | */ |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-jdk14</artifactId> |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Declare the version of the SLF4J API this implementation is compiled against. |
55 | * The value of this field is usually modified with each release. | |
55 | * The value of this field is modified with each major release. | |
56 | 56 | */ |
57 | 57 | // to avoid constant folding by the compiler, this field must *not* be final |
58 | 58 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final |
40 | 40 | |
41 | 41 | private StaticMDCBinder() { |
42 | 42 | } |
43 | ||
43 | ||
44 | /** | |
45 | * Return the singleton of this class. | |
46 | * | |
47 | * @return the StaticMDCBinder singleton | |
48 | * @since 1.7.14 | |
49 | */ | |
50 | public static final StaticMDCBinder getSingleton() { | |
51 | return SINGLETON; | |
52 | } | |
53 | ||
44 | 54 | /** |
45 | 55 | * Currently this method always returns an instance of |
46 | 56 | * {@link BasicMDCAdapter}. |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | * Return the singleton of this class. | |
52 | * | |
53 | * @return the StaticMarkerBinder singleton | |
54 | * @since 1.7.14 | |
55 | */ | |
56 | public static StaticMarkerBinder getSingleton() { | |
57 | return SINGLETON; | |
58 | } | |
59 | ||
60 | /** | |
51 | 61 | * Currently this method always returns an instance of |
52 | 62 | * {@link BasicMarkerFactory}. |
53 | 63 | */ |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-log4j12</artifactId> |
27 | 27 | import java.util.concurrent.ConcurrentMap; |
28 | 28 | |
29 | 29 | import org.apache.log4j.LogManager; |
30 | import org.slf4j.helpers.Util; | |
30 | 31 | import org.slf4j.ILoggerFactory; |
31 | 32 | import org.slf4j.Logger; |
32 | 33 | |
37 | 38 | * @author Ceki Gülcü |
38 | 39 | */ |
39 | 40 | public class Log4jLoggerFactory implements ILoggerFactory { |
41 | ||
42 | private static final String LOG4J_DELEGATION_LOOP_URL = "http://www.slf4j.org/codes.html#log4jDelegationLoop"; | |
43 | ||
44 | // check for delegation loops | |
45 | static { | |
46 | try { | |
47 | Class.forName("org.apache.log4j.Log4jLoggerFactory"); | |
48 | String part1 = "Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. "; | |
49 | String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL + " for more details."; | |
50 | ||
51 | Util.report(part1); | |
52 | Util.report(part2); | |
53 | throw new IllegalStateException(part1 + part2); | |
54 | } catch (ClassNotFoundException e) { | |
55 | // this is the good case | |
56 | } | |
57 | } | |
40 | 58 | |
41 | 59 | // key: name (String), value: a Log4jLoggerAdapter; |
42 | 60 | ConcurrentMap<String, Logger> loggerMap; |
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | * Declare the version of the SLF4J API this implementation is compiled | |
57 | * against. The value of this field is usually modified with each release. | |
56 | * Declare the version of the SLF4J API this implementation is compiled against. | |
57 | * The value of this field is modified with each major release. | |
58 | 58 | */ |
59 | 59 | // to avoid constant folding by the compiler, this field must *not* be final |
60 | 60 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final |
39 | 39 | |
40 | 40 | private StaticMDCBinder() { |
41 | 41 | } |
42 | ||
42 | ||
43 | /** | |
44 | * Return the singleton of this class. | |
45 | * | |
46 | * @return the StaticMDCBinder singleton | |
47 | * @since 1.7.14 | |
48 | */ | |
49 | public static final StaticMDCBinder getSingleton() { | |
50 | return SINGLETON; | |
51 | } | |
52 | ||
43 | 53 | /** |
44 | 54 | * Currently this method always returns an instance of |
45 | 55 | * {@link StaticMDCBinder}. |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | * Return the singleton of this class. | |
52 | * | |
53 | * @return the StaticMarkerBinder singleton | |
54 | * @since 1.7.14 | |
55 | */ | |
56 | public static StaticMarkerBinder getSingleton() { | |
57 | return SINGLETON; | |
58 | } | |
59 | ||
60 | /** | |
51 | 61 | * Currently this method always returns an instance of |
52 | 62 | * {@link BasicMarkerFactory}. |
53 | 63 | */ |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-migrator</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-nop</artifactId> |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Declare the version of the SLF4J API this implementation is compiled against. |
56 | * The value of this field is usually modified with each release. | |
56 | * The value of this field is modified with each major release. | |
57 | 57 | */ |
58 | 58 | // to avoid constant folding by the compiler, this field must *not* be final |
59 | 59 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | * Return the singleton of this class. | |
46 | * | |
47 | * @return the StaticMDCBinder singleton | |
48 | * @since 1.7.14 | |
49 | */ | |
50 | public static final StaticMDCBinder getSingleton() { | |
51 | return SINGLETON; | |
52 | } | |
53 | ||
54 | /** | |
45 | 55 | * Currently this method always returns an instance of |
46 | 56 | * {@link StaticMDCBinder}. |
47 | 57 | */ |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | * Return the singleton of this class. | |
52 | * | |
53 | * @return the StaticMarkerBinder singleton | |
54 | * @since 1.7.14 | |
55 | */ | |
56 | public static StaticMarkerBinder getSingleton() { | |
57 | return SINGLETON; | |
58 | } | |
59 | ||
60 | /** | |
51 | 61 | * Currently this method always returns an instance of |
52 | 62 | * {@link BasicMarkerFactory}. |
53 | 63 | */ |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.13</version> | |
9 | <version>1.7.14</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-simple</artifactId> |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | * Declare the version of the SLF4J API this implementation is compiled | |
56 | * against. The value of this field is usually modified with each release. | |
55 | * Declare the version of the SLF4J API this implementation is compiled against. | |
56 | * The value of this field is modified with each major release. | |
57 | 57 | */ |
58 | 58 | // to avoid constant folding by the compiler, this field must *not* be final |
59 | 59 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | * Return the singleton of this class. | |
46 | * | |
47 | * @return the StaticMDCBinder singleton | |
48 | * @since 1.7.14 | |
49 | */ | |
50 | public static final StaticMDCBinder getSingleton() { | |
51 | return SINGLETON; | |
52 | } | |
53 | ||
54 | /** | |
45 | 55 | * Currently this method always returns an instance of |
46 | 56 | * {@link StaticMDCBinder}. |
47 | 57 | */ |
47 | 47 | |
48 | 48 | private StaticMarkerBinder() { |
49 | 49 | } |
50 | ||
50 | ||
51 | /** | |
52 | * Return the singleton of this class. | |
53 | * | |
54 | * @return the StaticMarkerBinder singleton | |
55 | * @since 1.7.14 | |
56 | */ | |
57 | public static StaticMarkerBinder getSingleton() { | |
58 | return SINGLETON; | |
59 | } | |
60 | ||
51 | 61 | /** |
52 | 62 | * Currently this method always returns an instance of |
53 | 63 | * {@link BasicMarkerFactory}. |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
2 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
3 | ||
4 | <modelVersion>4.0.0</modelVersion> | |
5 | ||
6 | <parent> | |
7 | <groupId>org.slf4j</groupId> | |
8 | <artifactId>slf4j-parent</artifactId> | |
9 | <version>1.7.14</version> | |
10 | </parent> | |
11 | ||
12 | <artifactId>slf4j-site</artifactId> | |
13 | ||
14 | <packaging>jar</packaging> | |
15 | <name>SLF4J Site</name> | |
16 | <description>SLF4J Site</description> | |
17 | <url>http://www.slf4j.org</url> | |
18 | ||
19 | <build> | |
20 | <resources> | |
21 | <resource> | |
22 | <directory>${project.basedir}/src/site/pages</directory> | |
23 | <!-- The {project.basedir}/.. form breaks the eclipse plugin --> | |
24 | <targetPath>../../../target/site</targetPath> | |
25 | <filtering>true</filtering> | |
26 | </resource> | |
27 | <resource> | |
28 | <directory>${project.basedir}/src/main/resources</directory> | |
29 | </resource> | |
30 | </resources> | |
31 | <plugins> | |
32 | <plugin> | |
33 | <groupId>org.apache.maven.plugins</groupId> | |
34 | <artifactId>maven-site-plugin</artifactId> | |
35 | <version>${maven-site-plugin.version}</version> | |
36 | <configuration> | |
37 | <outputDirectory>${project.parent.basedir}/target/site</outputDirectory> | |
38 | </configuration> | |
39 | </plugin> | |
40 | </plugins> | |
41 | </build> | |
42 | ||
43 | </project>⏎ |