1 | |
package liquibase.logging; |
2 | |
|
3 | |
import liquibase.exception.ServiceNotFoundException; |
4 | |
import liquibase.servicelocator.ServiceLocator; |
5 | |
|
6 | |
import java.util.HashMap; |
7 | |
import java.util.Map; |
8 | |
|
9 | 0 | public class LogFactory { |
10 | 1 | private static Map<String, Logger> loggers = new HashMap<String, Logger>(); |
11 | 1 | private static String defaultLoggingLevel = "info"; |
12 | |
|
13 | |
public static Logger getLogger(String name) { |
14 | 582 | if (!loggers.containsKey(name)) { |
15 | |
Logger value; |
16 | |
try { |
17 | 1 | value = (Logger) ServiceLocator.getInstance().newInstance(Logger.class); |
18 | 0 | } catch (Exception e) { |
19 | 0 | throw new ServiceNotFoundException(e); |
20 | 1 | } |
21 | 1 | value.setName(name); |
22 | 1 | value.setLogLevel(defaultLoggingLevel); |
23 | 1 | loggers.put(name, value); |
24 | |
} |
25 | |
|
26 | 582 | return loggers.get(name); |
27 | |
} |
28 | |
|
29 | |
public static Logger getLogger() { |
30 | 582 | return getLogger("liquibase"); |
31 | |
} |
32 | |
|
33 | |
public static void setLoggingLevel(String defaultLoggingLevel) { |
34 | 0 | LogFactory.defaultLoggingLevel = defaultLoggingLevel; |
35 | 0 | } |
36 | |
} |