65 * <li> <handler-name>.size
66 * defines the buffer size (defaults to 1000). </li>
67 * <li> <handler-name>.push
68 * defines the <tt>pushLevel</tt> (defaults to <tt>level.SEVERE</tt>). </li>
69 * <li> <handler-name>.target
70 * specifies the name of the target <tt>Handler </tt> class.
71 * (no default). </li>
72 * </ul>
73 * <p>
74 * For example, the properties for {@code MemoryHandler} would be:
75 * <ul>
76 * <li> java.util.logging.MemoryHandler.level=INFO </li>
77 * <li> java.util.logging.MemoryHandler.formatter=java.util.logging.SimpleFormatter </li>
78 * </ul>
79 * <p>
80 * For a custom handler, e.g. com.foo.MyHandler, the properties would be:
81 * <ul>
82 * <li> com.foo.MyHandler.level=INFO </li>
83 * <li> com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter </li>
84 * </ul>
85 * <p>
86 * @since 1.4
87 */
88
89 public class MemoryHandler extends Handler {
90 private final static int DEFAULT_SIZE = 1000;
91 private volatile Level pushLevel;
92 private int size;
93 private Handler target;
94 private LogRecord buffer[];
95 int start, count;
96
97 /**
98 * Create a <tt>MemoryHandler</tt> and configure it based on
99 * <tt>LogManager</tt> configuration properties.
100 */
101 public MemoryHandler() {
102 // configure with specific defaults for MemoryHandler
103 super(Level.ALL, new SimpleFormatter(), null);
104
105 LogManager manager = LogManager.getLogManager();
250 pushLevel = newLevel;
251 }
252
253 /**
254 * Get the <tt>pushLevel</tt>.
255 *
256 * @return the value of the <tt>pushLevel</tt>
257 */
258 public Level getPushLevel() {
259 return pushLevel;
260 }
261
262 /**
263 * Check if this <tt>Handler</tt> would actually log a given
264 * <tt>LogRecord</tt> into its internal buffer.
265 * <p>
266 * This method checks if the <tt>LogRecord</tt> has an appropriate level and
267 * whether it satisfies any <tt>Filter</tt>. However it does <b>not</b>
268 * check whether the <tt>LogRecord</tt> would result in a "push" of the
269 * buffer contents. It will return false if the <tt>LogRecord</tt> is null.
270 * <p>
271 * @param record a <tt>LogRecord</tt>
272 * @return true if the <tt>LogRecord</tt> would be logged.
273 *
274 */
275 @Override
276 public boolean isLoggable(LogRecord record) {
277 return super.isLoggable(record);
278 }
279 }
|
65 * <li> <handler-name>.size
66 * defines the buffer size (defaults to 1000). </li>
67 * <li> <handler-name>.push
68 * defines the <tt>pushLevel</tt> (defaults to <tt>level.SEVERE</tt>). </li>
69 * <li> <handler-name>.target
70 * specifies the name of the target <tt>Handler </tt> class.
71 * (no default). </li>
72 * </ul>
73 * <p>
74 * For example, the properties for {@code MemoryHandler} would be:
75 * <ul>
76 * <li> java.util.logging.MemoryHandler.level=INFO </li>
77 * <li> java.util.logging.MemoryHandler.formatter=java.util.logging.SimpleFormatter </li>
78 * </ul>
79 * <p>
80 * For a custom handler, e.g. com.foo.MyHandler, the properties would be:
81 * <ul>
82 * <li> com.foo.MyHandler.level=INFO </li>
83 * <li> com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter </li>
84 * </ul>
85 *
86 * @since 1.4
87 */
88
89 public class MemoryHandler extends Handler {
90 private final static int DEFAULT_SIZE = 1000;
91 private volatile Level pushLevel;
92 private int size;
93 private Handler target;
94 private LogRecord buffer[];
95 int start, count;
96
97 /**
98 * Create a <tt>MemoryHandler</tt> and configure it based on
99 * <tt>LogManager</tt> configuration properties.
100 */
101 public MemoryHandler() {
102 // configure with specific defaults for MemoryHandler
103 super(Level.ALL, new SimpleFormatter(), null);
104
105 LogManager manager = LogManager.getLogManager();
250 pushLevel = newLevel;
251 }
252
253 /**
254 * Get the <tt>pushLevel</tt>.
255 *
256 * @return the value of the <tt>pushLevel</tt>
257 */
258 public Level getPushLevel() {
259 return pushLevel;
260 }
261
262 /**
263 * Check if this <tt>Handler</tt> would actually log a given
264 * <tt>LogRecord</tt> into its internal buffer.
265 * <p>
266 * This method checks if the <tt>LogRecord</tt> has an appropriate level and
267 * whether it satisfies any <tt>Filter</tt>. However it does <b>not</b>
268 * check whether the <tt>LogRecord</tt> would result in a "push" of the
269 * buffer contents. It will return false if the <tt>LogRecord</tt> is null.
270 *
271 * @param record a <tt>LogRecord</tt>
272 * @return true if the <tt>LogRecord</tt> would be logged.
273 *
274 */
275 @Override
276 public boolean isLoggable(LogRecord record) {
277 return super.isLoggable(record);
278 }
279 }
|