Package org.jboss.logmanager
Class LoggerNode
- java.lang.Object
-
- org.jboss.logmanager.LoggerNode
-
final class LoggerNode extends java.lang.ObjectA node in the tree of logger names. Maintains weak references to children and a strong reference to its parent.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Logger.AttachmentKey,java.lang.Object>attachmentsThe attachments map.private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LoggerNode,java.util.Map>attachmentsUpdaterThe atomic updater for theattachmentsfield.private java.util.concurrent.ConcurrentMap<java.lang.String,LoggerNode>childrenThe map of names to child nodes.private LogContextcontextThe log context.private inteffectiveLevelThe effective level.private java.util.logging.FilterfilterThe filter for this logger instance.private java.lang.StringfullNameThe fully-qualified name of this logger.private java.util.logging.Handler[]handlersThe handlers for this logger.private static AtomicArray<LoggerNode,java.util.logging.Handler>handlersUpdaterThe atomic updater for thehandlersfield.private java.util.logging.LevellevelThe actual level.private LoggerNodeparentThe parent node, ornullif this is the root logger node.private booleanuseParentFilterFlag to specify whether parent filters are used.private booleanuseParentHandlersFlag to specify whether parent handlers are used.
-
Constructor Summary
Constructors Modifier Constructor Description (package private)LoggerNode(LogContext context)Construct a new root instance.privateLoggerNode(LogContext context, LoggerNode parent, java.lang.String nodeName)Construct a child instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddHandler(java.util.logging.Handler handler)(package private) <V> Vattach(Logger.AttachmentKey<V> key, V value)(package private) <V> VattachIfAbsent(Logger.AttachmentKey<V> key, V value)(package private) java.util.logging.Handler[]clearHandlers()(package private) booleancompareAndSetHandlers(java.util.logging.Handler[] oldHandlers, java.util.logging.Handler[] newHandlers)(package private) LoggercreateLogger()(package private) voiddecrementRef()Removes one from the reference count.<V> Vdetach(Logger.AttachmentKey<V> key)protected voidfinalize()Perform finalization actions.(package private) <V> VgetAttachment(Logger.AttachmentKey<V> key)(package private) java.util.Collection<LoggerNode>getChildren()Get the children of this logger.(package private) LogContextgetContext()Get the log context.(package private) intgetEffectiveLevel()(package private) java.util.logging.FiltergetFilter()(package private) java.lang.StringgetFullName()(package private) java.util.logging.Handler[]getHandlers()(package private) LoggerNodegetIfExists(java.lang.String name)Get a relative logger, if it exists.(package private) java.util.logging.LevelgetLevel()(package private) LoggerNodegetOrCreate(java.lang.String name)Get or create a relative logger node.(package private) LoggerNodegetParent()(package private) booleangetUseParentFilters()(package private) booleangetUseParentHandlers()(package private) booleanisLoggable(ExtLogRecord record)Checks the filter to see if the record is loggable.private static booleanisLoggable(LoggerNode loggerNode, ExtLogRecord record)(package private) voidpublish(ExtLogRecord record)(package private) voidremoveHandler(java.util.logging.Handler handler)(package private) voidsetEffectiveLevel(int newLevel)Update the effective level if it is inherited from a parent.(package private) voidsetFilter(java.util.logging.Filter filter)(package private) java.util.logging.Handler[]setHandlers(java.util.logging.Handler[] handlers)(package private) voidsetLevel(java.util.logging.Level newLevel)(package private) voidsetUseParentFilters(boolean useParentFilter)(package private) voidsetUseParentHandlers(boolean useParentHandlers)
-
-
-
Field Detail
-
context
private final LogContext context
The log context.
-
parent
private final LoggerNode parent
The parent node, ornullif this is the root logger node.
-
fullName
private final java.lang.String fullName
The fully-qualified name of this logger.
-
children
private final java.util.concurrent.ConcurrentMap<java.lang.String,LoggerNode> children
The map of names to child nodes. The child node references are weak.
-
handlers
private volatile java.util.logging.Handler[] handlers
The handlers for this logger. May only be updated using thehandlersUpdateratomic updater. The array instance should not be modified (treat as immutable).
-
useParentHandlers
private volatile boolean useParentHandlers
Flag to specify whether parent handlers are used.
-
filter
private volatile java.util.logging.Filter filter
The filter for this logger instance.
-
useParentFilter
private volatile boolean useParentFilter
Flag to specify whether parent filters are used.
-
attachments
private volatile java.util.Map<Logger.AttachmentKey,java.lang.Object> attachments
The attachments map.
-
handlersUpdater
private static final AtomicArray<LoggerNode,java.util.logging.Handler> handlersUpdater
The atomic updater for thehandlersfield.
-
attachmentsUpdater
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LoggerNode,java.util.Map> attachmentsUpdater
The atomic updater for theattachmentsfield.
-
level
private volatile java.util.logging.Level level
The actual level. May only be modified when the context's level change lock is held; in addition, changing this field must be followed immediately by recursively updating the effective loglevel of the child tree.
-
effectiveLevel
private volatile int effectiveLevel
The effective level. May only be modified when the context's level change lock is held; in addition, changing this field must be followed immediately by recursively updating the effective loglevel of the child tree.
-
-
Constructor Detail
-
LoggerNode
LoggerNode(LogContext context)
Construct a new root instance.- Parameters:
context- the logmanager
-
LoggerNode
private LoggerNode(LogContext context, LoggerNode parent, java.lang.String nodeName)
Construct a child instance.- Parameters:
context- the logmanagerparent- the parent nodenodeName- the name of this subnode
-
-
Method Detail
-
getOrCreate
LoggerNode getOrCreate(java.lang.String name)
Get or create a relative logger node. The name is relatively qualified to this node.- Parameters:
name- the name- Returns:
- the corresponding logger node
-
getIfExists
LoggerNode getIfExists(java.lang.String name)
Get a relative logger, if it exists.- Parameters:
name- the name- Returns:
- the corresponding logger
-
createLogger
Logger createLogger()
-
decrementRef
void decrementRef()
Removes one from the reference count.
-
getChildren
java.util.Collection<LoggerNode> getChildren()
Get the children of this logger.- Returns:
- the children
-
getContext
LogContext getContext()
Get the log context.- Returns:
- the log context
-
setEffectiveLevel
void setEffectiveLevel(int newLevel)
Update the effective level if it is inherited from a parent. Must only be called while the logmanager's level change lock is held.- Parameters:
newLevel- the new effective level
-
setFilter
void setFilter(java.util.logging.Filter filter)
-
getFilter
java.util.logging.Filter getFilter()
-
getUseParentFilters
boolean getUseParentFilters()
-
setUseParentFilters
void setUseParentFilters(boolean useParentFilter)
-
getEffectiveLevel
int getEffectiveLevel()
-
getHandlers
java.util.logging.Handler[] getHandlers()
-
clearHandlers
java.util.logging.Handler[] clearHandlers()
-
removeHandler
void removeHandler(java.util.logging.Handler handler)
-
addHandler
void addHandler(java.util.logging.Handler handler)
-
setHandlers
java.util.logging.Handler[] setHandlers(java.util.logging.Handler[] handlers)
-
compareAndSetHandlers
boolean compareAndSetHandlers(java.util.logging.Handler[] oldHandlers, java.util.logging.Handler[] newHandlers)
-
getUseParentHandlers
boolean getUseParentHandlers()
-
setUseParentHandlers
void setUseParentHandlers(boolean useParentHandlers)
-
publish
void publish(ExtLogRecord record)
-
setLevel
void setLevel(java.util.logging.Level newLevel)
-
getLevel
java.util.logging.Level getLevel()
-
getAttachment
<V> V getAttachment(Logger.AttachmentKey<V> key)
-
attach
<V> V attach(Logger.AttachmentKey<V> key, V value)
-
attachIfAbsent
<V> V attachIfAbsent(Logger.AttachmentKey<V> key, V value)
-
detach
public <V> V detach(Logger.AttachmentKey<V> key)
-
getFullName
java.lang.String getFullName()
-
getParent
LoggerNode getParent()
-
isLoggable
boolean isLoggable(ExtLogRecord record)
Checks the filter to see if the record is loggable. If thegetUseParentFilters()is set totruethe parent loggers are checked.- Parameters:
record- the log record to check against the filter- Returns:
trueif the record is loggable, otherwisefalse
-
isLoggable
private static boolean isLoggable(LoggerNode loggerNode, ExtLogRecord record)
-
finalize
protected void finalize() throws java.lang.ThrowablePerform finalization actions. This amounts to clearing out the loglevel so that all children are updated with the parent's effective loglevel. As such, a lock is acquired from this method which might cause delays in garbage collection.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-