Class LoggerNode

java.lang.Object
org.jboss.logmanager.LoggerNode

final class LoggerNode extends Object
A node in the tree of logger names. Maintains weak references to children and a strong reference to its parent.
  • Field Details

    • 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 String fullName
      The fully-qualified name of this logger.
    • children

      private final ConcurrentMap<String,LoggerNode> children
      The map of names to child nodes. The child node references are weak.
    • handlers

      private volatile 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 Filter filter
      The filter for this logger instance.
    • useParentFilter

      private volatile boolean useParentFilter
      Flag to specify whether parent filters are used.
    • attachments

      private volatile Map<Logger.AttachmentKey,Object> attachments
      The attachments map.
    • handlersUpdater

      private static final AtomicArray<LoggerNode,Handler> handlersUpdater
      The atomic updater for the handlers field.
    • attachmentsUpdater

      private static final AtomicReferenceFieldUpdater<LoggerNode,Map> attachmentsUpdater
      The atomic updater for the attachments field.
    • level

      private volatile 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 Details

    • LoggerNode

      LoggerNode(LogContext context)
      Construct a new root instance.
      Parameters:
      context - the logmanager
    • LoggerNode

      private LoggerNode(LogContext context, LoggerNode parent, String nodeName)
      Construct a child instance.
      Parameters:
      context - the logmanager
      parent - the parent node
      nodeName - the name of this subnode
  • Method Details

    • getOrCreate

      LoggerNode getOrCreate(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(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

      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(Filter filter)
    • getFilter

      Filter getFilter()
    • getUseParentFilters

      boolean getUseParentFilters()
    • setUseParentFilters

      void setUseParentFilters(boolean useParentFilter)
    • getEffectiveLevel

      int getEffectiveLevel()
    • getHandlers

      Handler[] getHandlers()
    • clearHandlers

      Handler[] clearHandlers()
    • removeHandler

      void removeHandler(Handler handler)
    • addHandler

      void addHandler(Handler handler)
    • setHandlers

      Handler[] setHandlers(Handler[] handlers)
    • compareAndSetHandlers

      boolean compareAndSetHandlers(Handler[] oldHandlers, Handler[] newHandlers)
    • getUseParentHandlers

      boolean getUseParentHandlers()
    • setUseParentHandlers

      void setUseParentHandlers(boolean useParentHandlers)
    • publish

      void publish(ExtLogRecord record)
    • setLevel

      void setLevel(Level newLevel)
    • getLevel

      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

      String getFullName()
    • getParent

      LoggerNode getParent()
    • 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
    • isLoggable

      private static boolean isLoggable(LoggerNode loggerNode, ExtLogRecord record)
    • finalize

      protected void finalize() throws 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 Object
      Throws:
      Throwable