1 package com.atlassian.plugins.rest.module;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.slf4j.bridge.SLF4JBridgeHandler;
6
7
8
9
10
11
12 public final class Slf4jBridge {
13
14
15
16 private static final Logger log = LoggerFactory.getLogger(Slf4jBridge.class);
17
18
19
20
21
22
23
24
25
26
27
28 public static Helper createHelper() {
29 try {
30 Class.forName("org.slf4j.bridge.SLF4JBridgeHandler");
31
32 return new BridgePresentHelper();
33 } catch (ClassNotFoundException e) {
34 return new BridgeMissingHelper();
35 }
36 }
37
38 public interface Helper {
39
40
41
42 void install();
43
44
45
46
47 void uninstall();
48
49 }
50
51 private static class BridgeMissingHelper implements Helper {
52 public void install() {
53 log.debug("Skipping installation of SLF4JBridgeHandler for {}. Have you provided jcl-over-slf4j.jar?", Thread.currentThread().getContextClassLoader());
54 }
55
56 public void uninstall() {
57 }
58 }
59
60 private static class BridgePresentHelper implements Helper {
61 public void install() {
62 log.debug("Installing SLF4JBridgeHandler for {}.", Thread.currentThread().getContextClassLoader());
63 SLF4JBridgeHandler.install();
64 }
65
66 public void uninstall() {
67 SLF4JBridgeHandler.uninstall();
68 log.debug("Uninstalled SLF4JBridgeHandler for {}.", Thread.currentThread().getContextClassLoader());
69 }
70 }
71 }