Package io.microsphere.logging
Class LoggerFactory
- java.lang.Object
-
- io.microsphere.logging.LoggerFactory
-
- All Implemented Interfaces:
Prioritized,java.lang.Comparable<Prioritized>
- Direct Known Subclasses:
ACLLoggerFactory,JDKLoggerFactory,NoOpLoggerFactory,Sfl4jLoggerFactory
public abstract class LoggerFactory extends java.lang.Object implements Prioritized
TheLoggerFactoryserves as an abstract base class for creating and managing instances of theLoggertype. It also implements thePrioritizedinterface, allowing subclasses to define priority-based ordering.Implementations should provide the delegate logger class name and create a new logger instance using the provided name. Subclasses can override the methods to customize the behavior of logger creation and availability checks.
Example Usage
public class MyLoggerFactory extends LoggerFactory { private final String delegateLoggerClassName = "com.example.Logger"; public MyLoggerFactory() { // Set appropriate priority if needed } protected String getDelegateLoggerClassName() { return delegateLoggerClassName; } public Logger createLogger(String name) { return new MyLogger(name); } }- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
Logger,Prioritized
-
-
Field Summary
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description LoggerFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract LoggercreateLogger(java.lang.String name)Create a newLoggerprotected abstract java.lang.StringgetDelegateLoggerClassName()The class name of delegate Loggerstatic LoggergetLogger(java.lang.Class<?> type)Get an instance ofLoggerby typestatic LoggergetLogger(java.lang.String name)Get an instance ofLoggerby nameprotected booleanisAvailable()CurrentLoggerFactoryis available or not-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo, getPriority
-
-
-
-
Method Detail
-
getLogger
@Nonnull public static Logger getLogger(java.lang.Class<?> type)
Get an instance ofLoggerby type- Parameters:
type- the type- Returns:
- non-null
-
getLogger
@Nonnull public static Logger getLogger(java.lang.String name)
Get an instance ofLoggerby name
-
isAvailable
protected boolean isAvailable()
CurrentLoggerFactoryis available or not- Returns:
trueif available
-
getDelegateLoggerClassName
@Nonnull protected abstract java.lang.String getDelegateLoggerClassName()
The class name of delegate Logger- Returns:
- non-null
-
-