Methods Summary |
---|
public void | close()Close the Handler and free all associated resources.
This will also close the target Handler.
target.close();
setLevel(Level.OFF);
|
private void | configure()
// Private method to configure a ConsoleHandler from LogManager
// properties and/or default values as specified in the class
// javadoc.
LogManager manager = LogManager.getLogManager();
String cname = getClass().getName();
pushLevel = manager.getLevelProperty(cname +".push", Level.SEVERE);
size = manager.getIntProperty(cname + ".size", DEFAULT_SIZE);
if (size <= 0) {
size = DEFAULT_SIZE;
}
setLevel(manager.getLevelProperty(cname +".level", Level.ALL));
setFilter(manager.getFilterProperty(cname +".filter", null));
setFormatter(manager.getFormatterProperty(cname +".formatter", new SimpleFormatter()));
|
public void | flush()Causes a flush on the target Handler.
Note that the current contents of the MemoryHandler
buffer are not written out. That requires a "push".
target.flush();
|
public synchronized java.util.logging.Level | getPushLevel()Get the pushLevel.
return pushLevel;
|
private void | init()
buffer = new LogRecord[size];
start = 0;
count = 0;
|
public boolean | isLoggable(java.util.logging.LogRecord record)Check if this Handler would actually log a given
LogRecord into its internal buffer.
This method checks if the LogRecord has an appropriate level and
whether it satisfies any Filter. However it does not
check whether the LogRecord would result in a "push" of the
buffer contents. It will return false if the LogRecord is Null.
return super.isLoggable(record);
|
public synchronized void | publish(java.util.logging.LogRecord record)Store a LogRecord in an internal buffer.
If there is a Filter, its isLoggable
method is called to check if the given log record is loggable.
If not we return. Otherwise the given record is copied into
an internal circular buffer. Then the record's level property is
compared with the pushLevel. If the given level is
greater than or equal to the pushLevel then push
is called to write all buffered records to the target output
Handler.
if (!isLoggable(record)) {
return;
}
int ix = (start+count)%buffer.length;
buffer[ix] = record;
if (count < buffer.length) {
count++;
} else {
start++;
start %= buffer.length;
}
if (record.getLevel().intValue() >= pushLevel.intValue()) {
push();
}
|
public synchronized void | push()Push any buffered output to the target Handler.
The buffer is then cleared.
for (int i = 0; i < count; i++) {
int ix = (start+i)%buffer.length;
LogRecord record = buffer[ix];
target.publish(record);
}
// Empty the buffer.
start = 0;
count = 0;
|
public void | setPushLevel(java.util.logging.Level newLevel)Set the pushLevel. After a LogRecord is copied
into our internal buffer, if its level is greater than or equal to
the pushLevel, then push will be called.
if (newLevel == null) {
throw new NullPointerException();
}
LogManager manager = LogManager.getLogManager();
checkAccess();
pushLevel = newLevel;
|