|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.logging.Handler
bb.util.logging.HandlerAbstract
bb.util.logging.HandlerAudio
public class HandlerAudio
Plays a major error sound if a Level.SEVERE
LogRecord is encountered,
plays a minor error sound if a Level.WARNING
LogRecord is encountered,
or plays a notify sound if any other LogRecord is encountered.
(A LogRecord is "encountered" if it is passed to publish
and publish accepts it for publication.)
If, while the sound is playing, more LogRecords arrive, then the worst Level seen during this time determines what the next sound will be.
It can be useful to attach an instance to the root Logger, and have it publish serious logs.
It is unclear whether or not this class is multithread safe.
There may be issues with its superclass; see HandlerAbstract
for more discussion.
Concerning the state added by this class, every method is synchronized.
Nested Class Summary | |
---|---|
private static class |
HandlerAudio.SoundPlayer
|
static class |
HandlerAudio.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private Set<Level> |
levels
Stores the set of Levels encountered by publish since the last call to getLevelWorst . |
private Thread |
threadPlayer
Executes a HandlerAudio.SoundPlayer instance. |
Constructor Summary | |
---|---|
HandlerAudio()
Constructor. |
Method Summary | |
---|---|
void |
close()
First call releases all resources used by this instance. |
void |
flush()
Implementation here does nothing, since the notify done by publish effectively acts as an auto-flush if threadPlayer is waiting inside getLevelWorst. |
protected Level |
getLevelDefault()
Implementation here returns Level.WARNING . |
private Level |
getLevelWorst()
|
void |
publish(LogRecord record)
If isAlive or isLoggable (record) returns false, then immediately returns. |
Methods inherited from class bb.util.logging.HandlerAbstract |
---|
configure, getEncodingDefault, getFilterDefault, getFilterProperty, getFormatterDefault, getFormatterProperty, getIntProperty, getLevelProperty, getStringProperty, isAlive, isLoggable, setAlive |
Methods inherited from class java.util.logging.Handler |
---|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Set<Level> levels
publish
since the last call to getLevelWorst
.
Contract: is never null after construction, but is nulled out once and for all when close
is first called.
private Thread threadPlayer
HandlerAudio.SoundPlayer
instance.
Contract: is null until lazy initialized by publish
, then is nulled out once and for all when close
is first called.
Constructor Detail |
---|
public HandlerAudio()
All this instance's initial configuration comes from the LogManager
properties described in HandlerAbstract.configure
.
Method Detail |
---|
public void close()
publish
will be silently ignored.
close
in class HandlerAbstract
public void flush()
flush
in class Handler
public void publish(LogRecord record)
isAlive
or isLoggable
(record) returns false, then immediately returns.
Else, adds record's Level to levels
and notifies threadPlayer
if is waiting inside getLevelWorst
.
publish
in class Handler
protected Level getLevelDefault()
Level.WARNING
.
getLevelDefault
in class HandlerAbstract
private Level getLevelWorst() throws InterruptedException
InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |