|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.droplets.util.DropletLog
Provides an interface to the Droplet Server's log file. Java applications
can write structured messages to the file. There are four kinds of messages,
represented by four symbolic constants, one of which must be passed to each
invocation of write
:
DropletLog.DEBUG
- for messages useful only during
application development
DropletLog.ERROR
- indicates an error condition that may or
may not be fatal
DropletLog.INFO
- for messages that contain helpful
information that is not particularly alarming
DropletLog.WARNING
- in between ERROR and INFO in severity
Logging never throws an exception. Usually it succeeds, but if it fails for some reason, it fails silently. If, for example, the log file is being written to by another application or thread when you attempt to write to it, your thread will block, but only for a short period of time (< 1 second), after which it will silently discard the log message and return.
This class is a singleton, meaning that only one global (static) instance is
ever created. To write to the log, obtain the DropletLog
object by calling get()
, then call some method on the result.
For example:
DropletLog.get().write
(DropletLog.WARNING,
"myApplication",
"watch out, brother");
It is important that applications not cache this instance, but rather
re-obtain it for each method call, as shown above. Future implementations
of this class may support customizable, configurable logging strategies
that will require different objects to be returned under different
circumstances.
Field Summary | |
static int |
DEBUG
Deprecated. Pass to write as the messageType to
indicate that this is a debug message. |
static int |
ERROR
Deprecated. Pass to write as the messageType to
indicate that the message signals an error. |
static int |
INFO
Deprecated. Pass to write as the messageType to
indicate that the message is purely informative. |
static int |
WARNING
Deprecated. Pass to write as the messageType to
indicate that the message is a warning. |
Method Summary | |
static DropletLog |
get()
Deprecated. Returns the global singleton instance of DropletLog . |
void |
write(int messageType,
java.lang.String message)
Deprecated. Writes a message to the Droplet log, using the default subsystem name ("JavaDroplet"). |
void |
write(int messageType,
java.lang.String subsystemName,
java.lang.String message)
Deprecated. Writes a message to the Droplet log. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEBUG
write
as the messageType
to
indicate that this is a debug message.public static final int ERROR
write
as the messageType
to
indicate that the message signals an error.public static final int INFO
write
as the messageType
to
indicate that the message is purely informative.public static final int WARNING
write
as the messageType
to
indicate that the message is a warning.Method Detail |
public static DropletLog get()
DropletLog
.
Applications should
not cache this instance, but rather obtain it for each method call,
i.e.:
DropletLog.get().someMethod()
DropletLog
object on which logging methods can
be calledpublic void write(int messageType, java.lang.String message)
write(int, String, String)
instead.messageType
- one of the ERROR, WARNING, INFO, or DEBUG
symbolic constants. The type of the message will be indicated in
the log.message
- the text of the messagepublic void write(int messageType, java.lang.String subsystemName, java.lang.String message)
subsystemName
that is specific to your Droplet application so you can tell one
application's messages from another's.messageType
- one of the ERROR, WARNING, INFO, or DEBUG
symbolic constants. The type of the message will be indicated in
the log.subsystemName
- a key that will prefix the message in the logmessage
- the text of the message
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |