- All Superinterfaces:
Named
,Stringable
,StringSource
,Transmittable
,Triaged
- All Known Implementing Classes:
Activity
,Alert
,Announcement
,CriticalAlert
,EnsureProblem
,FatalProblem
,Glitch
,Information
,Narration
,OperationFailed
,OperationHalted
,OperationLifecycleMessage
,OperationMessage
,OperationStarted
,OperationStatusMessage
,OperationSucceeded
,Problem
,Quibble
,ReflectionProblem
,StepFailure
,StepIncomplete
,StepSuccess
,Trace
,Unsupported
,Warning
Formatter
to
produce a final formatted message, which can be retrieved with formatted(Formatter.Format)
. This is a useful
design because it is cheaper to construct messages if the formatting is delayed until the formatted string is need,
for example, when a log message is added to a formatted text log.
Message Attributes
text()
- The un-formatted text of the messagearguments()
- Arguments that can be applied to the message text when formatting itcause()
- Any exception associated with the messagecreated()
- The time that the message was createdseverity()
- The severity of the messageoperationStatus()
- The operation that the message relates to, if anystatus()
- The status of a step in an ongoing operation that the message relates to, if any
Types of Messages
Different types of messages relate to different aspects of a running program. Messages relating to a larger goal
of the program, such as converting a file or computing a route are operation lifecycle messages and extend
OperationLifecycleMessage
. Messages that relate to the smaller steps required to achieve an operation are
status messages and extend OperationStatusMessage
. If the operationStatus()
method returns a non-null
value, the message relates to the operation lifecycle. If the status()
method returns a non-null value the
message relates to the most recent step in the current operation.
Each class implementing Message
will define one or the other of these two return values. For example,
OperationHalted
is a lifecycle message which means that the current operation has transitioned to the
Message.OperationStatus.HALTED
state. Warning
relates to a step in an operation which Message.Status.SUCCEEDED
,
even if it did so imperfectly. Inspection of message classes will reveal what their meaning is with respect to
operations and the steps used to complete them.
Operation Lifecycle Messages
An Message.OperationStatus
lifecycle message relates to a state change in the status of an operation. Operations start,
run and then complete with some kind of result:
Message.OperationStatus.STARTED
- The operation has startedMessage.OperationStatus.RUNNING
- The operation is runningMessage.OperationStatus.SUCCEEDED
- The operation completed successfullyMessage.OperationStatus.FAILED
- The operation completed but did not succeed in meeting its goalMessage.OperationStatus.HALTED
- The operation was unable to complete
Operation Status Messages
A Message.Status
message relates to the result of executing a step in a larger operation:
Message.Status.SUCCEEDED
- The step succeeded and the message is reporting progress:Activity
,Information
,StepSuccess
,Trace
Message.Status.COMPLETED
- The step completed and produced a result but there was an actual or potential negative effect that should be noted: {Warning
}Message.Status.RESULT_COMPROMISED
- The step completed successfully amd data was not discarded, but the result may be partly invalid:Glitch
Message.Status.RESULT_INCOMPLETE
- The step completed but some aspect of the result had to be discarded:StepIncomplete
Message.Status.PROBLEM
- The step didn't complete correctly because something needs attention:Problem
Message.Status.FAILED
- The step did not complete or did not produce any usable result:Alert
,CriticalAlert
,StepFailure
- Author:
- jonathanl (shibo)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
The meaning of a message if it represents a state change in the lifecycle of an operationstatic enum
The meaning of a message if it relates to the current step in an ongoing operationNested classes/interfaces inherited from interface com.telenav.kivakit.interfaces.string.Stringable
Stringable.Format
-
Method Summary
Modifier and TypeMethodDescriptionObject[]
cause()
Not public APIcontext()
created()
static String
default String
formatted
(Formatter.Format format) default boolean
default boolean
isMoreImportantThan
(Class<? extends Message> type) default boolean
isMoreImportantThanOrEqualTo
(Class<? extends Message> type) default boolean
isWorseThan
(Message.Status status) default <T extends Message>
booleanisWorseThan
(Class<T> message) default boolean
isWorseThanOrEqualTo
(Message.Status status) default <T extends Message>
booleanisWorseThanOrEqualTo
(Class<T> message) default String
name()
static Message
parseMessageName
(Listener listener, String name) severity()
status()
text()
default void
default void
toString()
The formatted message, including any exceptionMethods inherited from interface com.telenav.kivakit.interfaces.string.Stringable
asString, asString
-
Method Details
-
escape
- Returns:
- The given string with single quotes escaped
-
arguments
Object[] arguments()- Returns:
- Message arguments used to produce formatted message
-
asException
RuntimeException asException()- Returns:
- This message as an exception
-
cause
Throwable cause()- Returns:
- Any cause or null if none
-
cause
Not public APISets the cause for this message
-
context
CodeContext context()- Returns:
- The context where this message was created
-
created
Time created()- Returns:
- The time at which this message was created
-
description
String description()- Returns:
- The formatted message without stack trace information
-
formatted
-
importance
Importance importance()- Returns:
- The importance of this message, without respect to severity
-
isFailure
default boolean isFailure() -
isMoreImportantThan
-
isMoreImportantThanOrEqualTo
-
isWorseThan
- Returns:
- True if the status of this message is worse than the given message
-
isWorseThanOrEqualTo
- Returns:
- True if the status of this message is worse than the given message
-
maximumFrequency
Frequency maximumFrequency()- Returns:
- The frequency with which this message should be logged or null if the message should always be logged.
NOTE: Message identity is determined by looking at the un-formatted message returned by message(). If message() does not return a constant string, a bounded map error may occur as the system attempts to track too many message frequencies.
-
name
-
operationStatus
Message.OperationStatus operationStatus()- Returns:
- The operational status represented by this message, if any
-
severity
Severity severity() -
stackTrace
StackTrace stackTrace()- Returns:
- Any stack trace associated with this message (or null if none applies)
-
status
Message.Status status()- Returns:
- The status of a step in an ongoing operation, if the message is relevant to this
-
text
String text()- Returns:
- The un-formatted message text. See
Formatter.format(String, Object...)
for details on how this text is formatted using thearguments()
to the message.
-
throwAsIllegalArgumentException
default void throwAsIllegalArgumentException() -
throwAsIllegalStateException
default void throwAsIllegalStateException() -
toString
String toString()The formatted message, including any exception
-