Package org.jboss.logmanager
Class LoggerNode
java.lang.Object
org.jboss.logmanager.LoggerNode
A node in the tree of logger names. Maintains weak references to children and a strong reference to its parent.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map
<Logger.AttachmentKey, Object> The attachments map.private static final AtomicReferenceFieldUpdater
<LoggerNode, Map> The atomic updater for theattachments
field.private final ConcurrentMap
<String, LoggerNode> The map of names to child nodes.private final LogContext
The log context.private int
The effective level.private Filter
The filter for this logger instance.private final String
The fully-qualified name of this logger.private Handler[]
The handlers for this logger.private static final AtomicArray
<LoggerNode, Handler> The atomic updater for thehandlers
field.private Level
The actual level.private final LoggerNode
The parent node, ornull
if this is the root logger node.private boolean
Flag to specify whether parent filters are used.private boolean
Flag to specify whether parent handlers are used. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
LoggerNode
(LogContext context) Construct a new root instance.private
LoggerNode
(LogContext context, LoggerNode parent, String nodeName) Construct a child instance. -
Method Summary
Modifier and TypeMethodDescription(package private) void
addHandler
(Handler handler) (package private) <V> V
attach
(Logger.AttachmentKey<V> key, V value) (package private) <V> V
attachIfAbsent
(Logger.AttachmentKey<V> key, V value) (package private) Handler[]
(package private) boolean
compareAndSetHandlers
(Handler[] oldHandlers, Handler[] newHandlers) (package private) Logger
(package private) void
Removes one from the reference count.<V> V
detach
(Logger.AttachmentKey<V> key) protected void
finalize()
Perform finalization actions.(package private) <V> V
getAttachment
(Logger.AttachmentKey<V> key) (package private) Collection
<LoggerNode> Get the children of this logger.(package private) LogContext
Get the log context.(package private) int
(package private) Filter
(package private) String
(package private) Handler[]
(package private) LoggerNode
getIfExists
(String name) Get a relative logger, if it exists.(package private) Level
getLevel()
(package private) LoggerNode
getOrCreate
(String name) Get or create a relative logger node.(package private) LoggerNode
(package private) boolean
(package private) boolean
(package private) boolean
isLoggable
(ExtLogRecord record) Checks the filter to see if the record is loggable.private static boolean
isLoggable
(LoggerNode loggerNode, ExtLogRecord record) (package private) void
publish
(ExtLogRecord record) (package private) void
removeHandler
(Handler handler) (package private) void
setEffectiveLevel
(int newLevel) Update the effective level if it is inherited from a parent.(package private) void
(package private) Handler[]
setHandlers
(Handler[] handlers) (package private) void
(package private) void
setUseParentFilters
(boolean useParentFilter) (package private) void
setUseParentHandlers
(boolean useParentHandlers)
-
Field Details
-
context
The log context. -
parent
The parent node, ornull
if this is the root logger node. -
fullName
The fully-qualified name of this logger. -
children
The map of names to child nodes. The child node references are weak. -
handlers
The handlers for this logger. May only be updated using thehandlersUpdater
atomic updater. The array instance should not be modified (treat as immutable). -
useParentHandlers
private volatile boolean useParentHandlersFlag to specify whether parent handlers are used. -
filter
The filter for this logger instance. -
useParentFilter
private volatile boolean useParentFilterFlag to specify whether parent filters are used. -
attachments
The attachments map. -
handlersUpdater
The atomic updater for thehandlers
field. -
attachmentsUpdater
The atomic updater for theattachments
field. -
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 effectiveLevelThe 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 Details
-
LoggerNode
LoggerNode(LogContext context) Construct a new root instance.- Parameters:
context
- the logmanager
-
LoggerNode
Construct a child instance.- Parameters:
context
- the logmanagerparent
- the parent nodenodeName
- the name of this subnode
-
-
Method Details
-
getOrCreate
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
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
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
-
getFilter
Filter getFilter() -
getUseParentFilters
boolean getUseParentFilters() -
setUseParentFilters
void setUseParentFilters(boolean useParentFilter) -
getEffectiveLevel
int getEffectiveLevel() -
getHandlers
Handler[] getHandlers() -
clearHandlers
Handler[] clearHandlers() -
removeHandler
-
addHandler
-
setHandlers
-
compareAndSetHandlers
-
getUseParentHandlers
boolean getUseParentHandlers() -
setUseParentHandlers
void setUseParentHandlers(boolean useParentHandlers) -
publish
-
setLevel
-
getLevel
Level getLevel() -
getAttachment
-
attach
-
attachIfAbsent
-
detach
-
getFullName
String getFullName() -
getParent
LoggerNode getParent() -
isLoggable
Checks the filter to see if the record is loggable. If thegetUseParentFilters()
is set totrue
the parent loggers are checked.- Parameters:
record
- the log record to check against the filter- Returns:
true
if the record is loggable, otherwisefalse
-
isLoggable
-
finalize
Perform 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.
-