Пример #1
0
 /**
  * Gets the tail string used to wrap a set of log records. This base class
  * always returns the empty string.
  *
  * @param h
  *            the target handler.
  * @return the tail string used to wrap a set of log records, empty in this
  *         implementation.
  */
 public String getTail(Handler h)
 {
     return ""; //$NON-NLS-1$
 }
Пример #2
0
 /**
  * Default constructor, construct and init a {@code MemoryHandler} using
  * {@code LogManager} properties or default values.
  *
  * @throws RuntimeException
  *             if property value are invalid and no default value could be
  *             used.
  */
 public MemoryHandler()
     : base()
 {
     String className = this.getClass().getName();
     // init target
     String targetName = manager.getProperty(className + ".target"); //$NON-NLS-1$
     try {
     target = (Handler) java.lang.Class.forName(targetName).newInstance();
             } catch (Exception e) {
     // logging.10=Cannot load target handler:{0}
     throw new java.lang.RuntimeException("Cannot load target handler: "+ //$NON-NLS-1$
             targetName);
     }
     // init size
     String sizeString = manager.getProperty(className + ".size"); //$NON-NLS-1$
     if (null != sizeString) {
     try {
         size = java.lang.Integer.parseInt(sizeString);
         if (size <= 0) {
             size = DEFAULT_SIZE;
         }
     } catch (java.lang.Exception e) {
         printInvalidPropMessage(className + ".size", sizeString, e); //$NON-NLS-1$
     }
     }
     // init push level
     String pushName = manager.getProperty(className + ".push"); //$NON-NLS-1$
     if (null != pushName) {
     try {
         pushJ = Level.parse(pushName);
     } catch (java.lang.Exception e) {
         printInvalidPropMessage(className + ".push", pushName, e); //$NON-NLS-1$
     }
     }
     // init other properties which are common for all Handler
     initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
     buffer = new LogRecord[size];
 }
Пример #3
0
 /**
  * Gets the head string used to wrap a set of log records. This base class
  * always returns an empty string.
  *
  * @param h
  *            the target handler.
  * @return the head string used to wrap a set of log records, empty in this
  *         implementation.
  */
 public String getHead(Handler h)
 {
     return ""; //$NON-NLS-1$
 }
Пример #4
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];
 }