Class 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 Detail

      • context

        private final LogContext context
        The log context.
      • parent

        private final LoggerNode parent
        The parent node, or null 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 the handlersUpdater 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 the handlers field.
      • attachmentsUpdater

        private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LoggerNode,​java.util.Map> attachmentsUpdater
        The atomic updater for the attachments 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 logmanager
        parent - the parent node
        nodeName - 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)
      • setLevel

        void setLevel​(java.util.logging.Level newLevel)
      • getLevel

        java.util.logging.Level getLevel()
      • getFullName

        java.lang.String getFullName()
      • isLoggable

        boolean isLoggable​(ExtLogRecord record)
        Checks the filter to see if the record is loggable. If the getUseParentFilters() is set to true the parent loggers are checked.
        Parameters:
        record - the log record to check against the filter
        Returns:
        true if the record is loggable, otherwise false
      • 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 class java.lang.Object
        Throws:
        java.lang.Throwable