1 package org.slf4j.impl;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.slf4j.ILoggerFactory;
23 import org.slf4j.spi.LoggerFactoryBinder;
24
25 /**
26 * SLF4J LoggerFactoryBinder implementation using MavenSimpleLogger.
27 * This class is part of the required classes used to specify an
28 * SLF4J logger provider implementation.
29 *
30 * @since 3.5.1
31 */
32 public final class StaticLoggerBinder
33 implements LoggerFactoryBinder
34 {
35 /**
36 * Declare the version of the SLF4J API this implementation is compiled
37 * against. The value of this field is usually modified with each release.
38 */
39 // to avoid constant folding by the compiler, this field must *not* be final
40 @SuppressWarnings( { "checkstyle:staticvariablename", "checkstyle:visibilitymodifier" } )
41 public static String REQUESTED_API_VERSION = "1.7.25"; // !final
42
43 private static final String LOGGER_FACTORY_CLASS_STR = MavenSimpleLoggerFactory.class.getName();
44
45 /**
46 * The unique instance of this class.
47 */
48 private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
49
50 /**
51 * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
52 * method should always be the same object
53 */
54 private final ILoggerFactory loggerFactory;
55
56 /**
57 * Private constructor to prevent instantiation
58 */
59 private StaticLoggerBinder()
60 {
61 loggerFactory = new MavenSimpleLoggerFactory();
62 }
63
64 /**
65 * Returns the singleton of this class.
66 */
67 public static StaticLoggerBinder getSingleton()
68 {
69 return SINGLETON;
70 }
71
72 /**
73 * Returns the factory.
74 */
75 @Override
76 public ILoggerFactory getLoggerFactory()
77 {
78 return loggerFactory;
79 }
80
81 /**
82 * Returns the class name.
83 */
84 @Override
85 public String getLoggerFactoryClassStr()
86 {
87 return LOGGER_FACTORY_CLASS_STR;
88 }
89 }