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
17 private static final Logger log = LoggerFactory.getLogger(Slf4jBridge.class);
18
19
20
21
22
23
24
25
26
27
28
29 public static Helper createHelper()
30 {
31 try
32 {
33 Class.forName("org.slf4j.bridge.SLF4JBridgeHandler");
34
35 return new BridgePresentHelper();
36 }
37 catch (ClassNotFoundException e)
38 {
39 return new BridgeMissingHelper();
40 }
41 }
42
43 public interface Helper
44 {
45
46
47
48 void install();
49
50
51
52
53 void uninstall();
54
55 }
56
57 private static class BridgeMissingHelper implements Helper
58 {
59 public void install()
60 {
61 log.debug("Skipping installation of SLF4JBridgeHandler for {}. Have you provided jcl-over-slf4j.jar?", Thread.currentThread().getContextClassLoader());
62 }
63
64 public void uninstall()
65 {
66 }
67 }
68
69 private static class BridgePresentHelper implements Helper
70 {
71 public void install()
72 {
73 log.debug("Installing SLF4JBridgeHandler for {}.", Thread.currentThread().getContextClassLoader());
74 SLF4JBridgeHandler.install();
75 }
76
77 public void uninstall()
78 {
79 SLF4JBridgeHandler.uninstall();
80 log.debug("Uninstalled SLF4JBridgeHandler for {}.", Thread.currentThread().getContextClassLoader());
81 }
82 }
83 }