Package org.jboss.logmanager
Class LoggerNode
- java.lang.Object
-
- org.jboss.logmanager.LoggerNode
-
final class LoggerNode extends java.lang.Object
A 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>
attachments
The attachments map.private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LoggerNode,java.util.Map>
attachmentsUpdater
The atomic updater for theattachments
field.private java.util.concurrent.ConcurrentMap<java.lang.String,LoggerNode>
children
The map of names to child nodes.private LogContext
context
The log context.private int
effectiveLevel
The effective level.private java.util.logging.Filter
filter
The filter for this logger instance.private java.lang.String
fullName
The fully-qualified name of this logger.private java.util.logging.Handler[]
handlers
The handlers for this logger.private static AtomicArray<LoggerNode,java.util.logging.Handler>
handlersUpdater
The atomic updater for thehandlers
field.private java.util.logging.Level
level
The actual level.private LoggerNode
parent
The parent node, ornull
if this is the root logger node.private boolean
useParentFilter
Flag to specify whether parent filters are used.private boolean
useParentHandlers
Flag to specify whether parent handlers are used.
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
LoggerNode(LogContext context)
Construct a new root instance.private
LoggerNode(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) void
addHandler(java.util.logging.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) java.util.logging.Handler[]
clearHandlers()
(package private) boolean
compareAndSetHandlers(java.util.logging.Handler[] oldHandlers, java.util.logging.Handler[] newHandlers)
(package private) Logger
createLogger()
(package private) void
decrementRef()
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) java.util.Collection<LoggerNode>
getChildren()
Get the children of this logger.(package private) LogContext
getContext()
Get the log context.(package private) int
getEffectiveLevel()
(package private) java.util.logging.Filter
getFilter()
(package private) java.lang.String
getFullName()
(package private) java.util.logging.Handler[]
getHandlers()
(package private) LoggerNode
getIfExists(java.lang.String name)
Get a relative logger, if it exists.(package private) java.util.logging.Level
getLevel()
(package private) LoggerNode
getOrCreate(java.lang.String name)
Get or create a relative logger node.(package private) LoggerNode
getParent()
(package private) boolean
getUseParentFilters()
(package private) boolean
getUseParentHandlers()
(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(java.util.logging.Handler handler)
(package private) void
setEffectiveLevel(int newLevel)
Update the effective level if it is inherited from a parent.(package private) void
setFilter(java.util.logging.Filter filter)
(package private) java.util.logging.Handler[]
setHandlers(java.util.logging.Handler[] handlers)
(package private) void
setLevel(java.util.logging.Level newLevel)
(package private) void
setUseParentFilters(boolean useParentFilter)
(package private) void
setUseParentHandlers(boolean useParentHandlers)
-
-
-
Field Detail
-
context
private final LogContext context
The log context.
-
parent
private final LoggerNode parent
The parent node, ornull
if 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 thehandlersUpdater
atomic 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 thehandlers
field.
-
attachmentsUpdater
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LoggerNode,java.util.Map> attachmentsUpdater
The atomic updater for theattachments
field.
-
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 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
private static boolean isLoggable(LoggerNode loggerNode, ExtLogRecord record)
-
finalize
protected void finalize() throws java.lang.Throwable
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.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-