Exemplo n.º 1
0
        /*
         * Sets the level on {@code logger} to {@code newLevel}. Any child loggers
         * currently inheriting their level from {@code logger} will be updated
         * recursively.
         *
         * @param newLevel the new minimum logging threshold. If null, the logger's
         *      parent level will be used; or {@code Level.INFO} for loggers with no
         *      parent.
         */
        internal void setLevelRecursively(Logger logger, Level newLevel)
        {
            lock (this)
            {
                int previous = logger.levelIntVal;
                logger.levelObjVal = newLevel;

                if (newLevel == null)
                {
                    logger.levelIntVal = logger.parent != null
                            ? logger.parent.levelIntVal
                            : Level.INFO.intValue();
                }
                else
                {
                    logger.levelIntVal = newLevel.intValue();
                }

                if (previous != logger.levelIntVal)
                {
                    foreach (Logger child in logger.children)
                    {
                        if (child.levelObjVal == null)
                        {
                            setLevelRecursively(child, null);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /**
         * This method is for compatibility. Tests written to the reference
         * implementation API imply that the isLoggable() method is not called
         * directly. This behavior is important because subclass may override
         * isLoggable() method, so that affect the result of log methods.
         */
        private bool internalIsLoggable(Level l)
        {
            int effectiveLevel = levelIntVal;

            if (effectiveLevel == Level.OFF.intValue())
            {
                // always return false if the effective level is off
                return(false);
            }
            return(l.intValue() >= effectiveLevel);
        }
Exemplo n.º 3
0
 /*
  * Construct and init a {@code MemoryHandler} using given target, size and
  * push level, other properties using {@code LogManager} properties or
  * default values.
  *
  * @param target
  *            the given {@code Handler} to output
  * @param size
  *            the maximum number of buffered {@code LogRecord}, greater than
  *            zero
  * @param pushLevel
  *            the push level
  * @throws IllegalArgumentException
  *             if {@code size <= 0}
  * @throws RuntimeException
  *             if property value are invalid and no default value could be
  *             used.
  */
 public MemoryHandler(Handler target, int size, Level pushLevel)
 {
     if (size <= 0)
     {
         // logging.11=Size must be positive.
         throw new java.lang.IllegalArgumentException("Size must be positive."); //$NON-NLS-1$
     }
     target.getLevel();
     pushLevel.intValue();
     this.target = target;
     this.size   = size;
     this.pushJ  = pushLevel;
     initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
     buffer = new LogRecord[size];
 }
Exemplo n.º 4
0
 /*
  * Put a given {@code LogRecord} into internal buffer. If given record is
  * not loggable, just return. Otherwise it is stored in the buffer.
  * Furthermore if the record's level is not less than the push level, the
  * push action is triggered to output all the buffered records to the target
  * handler, and the target handler will publish them.
  *
  * @param record
  *            the log record
  */
 public override void publish(LogRecord record)
 {
     lock (this) {
         if (!isLoggable(record))
         {
             return;
         }
         if (cursor >= size)
         {
             cursor = 0;
         }
         buffer[cursor++] = record;
         if (record.getLevel().intValue() >= pushJ.intValue())
         {
             push();
         }
         return;
     }
 }
Exemplo n.º 5
0
 /*
  * Set the push level. The push level is used to check the push action
  * triggering. When a new {@code LogRecord} is put into the internal
  * buffer and its level is not less than the push level, the push action
  * will be triggered. Note that set new push level won't trigger push action.
  *
  * @param newLevel
  *                 the new level to set.
  * @throws SecurityException
  *                 if security manager exists and it determines that caller
  *                 does not have the required permissions to control this handler.
  */
 public void setPushLevel(Level newLevel)
 {
     manager.checkAccess();
     newLevel.intValue();
     this.pushJ = newLevel;
 }
Exemplo n.º 6
0
        /**
         * Sets the level on {@code logger} to {@code newLevel}. Any child loggers
         * currently inheriting their level from {@code logger} will be updated
         * recursively.
         *
         * @param newLevel the new minimum logging threshold. If null, the logger's
         *      parent level will be used; or {@code Level.INFO} for loggers with no
         *      parent.
         */
        internal void setLevelRecursively(Logger logger, Level newLevel)
        {
            lock (this)
            {
                int previous = logger.levelIntVal;
                logger.levelObjVal = newLevel;

                if (newLevel == null)
                {
                    logger.levelIntVal = logger.parent != null
                            ? logger.parent.levelIntVal
                            : Level.INFO.intValue();
                }
                else
                {
                    logger.levelIntVal = newLevel.intValue();
                }

                if (previous != logger.levelIntVal)
                {
                    foreach (Logger child in logger.children)
                    {
                        if (child.levelObjVal == null)
                        {
                            setLevelRecursively(child, null);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
 /**
  * Set the push level. The push level is used to check the push action
  * triggering. When a new {@code LogRecord} is put into the internal
  * buffer and its level is not less than the push level, the push action
  * will be triggered. Note that set new push level won't trigger push action.
  *
  * @param newLevel
  *                 the new level to set.
  * @throws SecurityException
  *                 if security manager exists and it determines that caller
  *                 does not have the required permissions to control this handler.
  */
 public void setPushLevel(Level newLevel)
 {
     manager.checkAccess();
     newLevel.intValue();
     this.pushJ = newLevel;
 }
Exemplo n.º 8
0
 /**
  * Construct and init a {@code MemoryHandler} using given target, size and
  * push level, other properties using {@code LogManager} properties or
  * default values.
  *
  * @param target
  *            the given {@code Handler} to output
  * @param size
  *            the maximum number of buffered {@code LogRecord}, greater than
  *            zero
  * @param pushLevel
  *            the push level
  * @throws IllegalArgumentException
  *             if {@code size <= 0}
  * @throws RuntimeException
  *             if property value are invalid and no default value could be
  *             used.
  */
 public MemoryHandler(Handler target, int size, Level pushLevel)
 {
     if (size <= 0) {
     // logging.11=Size must be positive.
     throw new java.lang.IllegalArgumentException("Size must be positive."); //$NON-NLS-1$
     }
     target.getLevel();
     pushLevel.intValue();
     this.target = target;
     this.size = size;
     this.pushJ = pushLevel;
     initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
     buffer = new LogRecord[size];
 }
Exemplo n.º 9
0
 /**
  * This method is for compatibility. Tests written to the reference
  * implementation API imply that the isLoggable() method is not called
  * directly. This behavior is important because subclass may override
  * isLoggable() method, so that affect the result of log methods.
  */
 private bool internalIsLoggable(Level l)
 {
     int effectiveLevel = levelIntVal;
     if (effectiveLevel == Level.OFF.intValue())
     {
         // always return false if the effective level is off
         return false;
     }
     return l.intValue() >= effectiveLevel;
 }