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
TheLoggerFactory
serves as an abstract base class for creating and managing instances of theLogger
type. It also implements thePrioritized
interface, 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 Logger
createLogger(java.lang.String name)
Create a newLogger
protected abstract java.lang.String
getDelegateLoggerClassName()
The class name of delegate Loggerstatic Logger
getLogger(java.lang.Class<?> type)
Get an instance ofLogger
by typestatic Logger
getLogger(java.lang.String name)
Get an instance ofLogger
by nameprotected boolean
isAvailable()
CurrentLoggerFactory
is 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 ofLogger
by type- Parameters:
type
- the type- Returns:
- non-null
-
getLogger
@Nonnull public static Logger getLogger(java.lang.String name)
Get an instance ofLogger
by name
-
isAvailable
protected boolean isAvailable()
CurrentLoggerFactory
is available or not- Returns:
true
if available
-
getDelegateLoggerClassName
@Nonnull protected abstract java.lang.String getDelegateLoggerClassName()
The class name of delegate Logger- Returns:
- non-null
-
-