Class StampedMessage
- java.lang.Object
-
- com.identityworksllc.iiq.common.vo.StampedMessage
-
- All Implemented Interfaces:
Serializable
@JsonClassDescription("A message associated with a timestamp, akin to a log message from any logger tool") public class StampedMessage extends Object implements Serializable
Implements a timestamped log message similar to what would be captured by a logging framework.However, this one can be passed around as a VO for UI and other purposes.
It is serialized to JSON by
StampedMessageSerializer
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StampedMessage.Builder
A Builder for a StampedMessage, allowing a fluent API if needed
-
Constructor Summary
Constructors Constructor Description StampedMessage(@NonNull LogLevel level, String message)
Creates a basic log of the given level with the given string messageStampedMessage(@NonNull LogLevel level, String message, Throwable exception)
Full constructor taking a level, a message, and an exception.StampedMessage(@NonNull String message)
Creates a basic INFO level log with the given string messageStampedMessage(@NonNull Throwable throwable)
Creates a log of ERROR level with the given Throwable, using its getMessage() as the messageStampedMessage(@NonNull sailpoint.tools.Message message)
Creates a log from a SailPoint Message objectStampedMessage(@NonNull sailpoint.tools.Message message, Throwable throwable)
Creates a log from a SailPoint Message object and a throwableStampedMessage(String message, Throwable throwable)
Creates a log of ERROR level with the given message and Throwable
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StampedMessage.Builder
builder()
Constructs a new, emptyStampedMessage.Builder
static StampedMessage.Builder
builder(StampedMessage copy)
Constructs a builder from an existingStampedMessage
Throwable
getException()
Gets the exception associated with this LogMessageLogLevel
getLevel()
Gets the log level associated with this LogMessageString
getMessage()
Gets the log messageString
getThread()
Returns the thread associated with thislong
getTimestamp()
Gets the millisecond timestamp when this object was createdboolean
isDebug()
Returns true if the log level of this message is exactly DEBUGboolean
isError()
Returns true if the log level of this message is exactly ERRORboolean
isInfo()
Returns true if the log level of this message is exactly INFOboolean
isInfoOrHigher()
Returns true if the log level of this message is INFO, WARN, or ERRORboolean
isWarning()
Returns true if the log level of this message is WARNboolean
isWarningOrHigher()
Returns true if the log level of this message is WARN or ERRORMap<String,String>
toMap()
Transforms this object to a Map of strings, suitable for passing to a client as JSON or XML.String
toString()
Transforms this object into a log4j-type log string.
-
-
-
Constructor Detail
-
StampedMessage
public StampedMessage(@NonNull @NonNull LogLevel level, String message)
Creates a basic log of the given level with the given string message- Parameters:
level
- The log levelmessage
- The message
-
StampedMessage
public StampedMessage(@NonNull @NonNull LogLevel level, String message, Throwable exception)
Full constructor taking a level, a message, and an exception.The log timestamp will be the system timestamp when this constructor is invoked.
- Parameters:
level
- The log levelmessage
- The string messageexception
- The exception (or null)
-
StampedMessage
public StampedMessage(@NonNull @NonNull sailpoint.tools.Message message)
Creates a log from a SailPoint Message object- Parameters:
message
- A Sailpoint message
-
StampedMessage
public StampedMessage(@NonNull @NonNull sailpoint.tools.Message message, Throwable throwable)
Creates a log from a SailPoint Message object and a throwable- Parameters:
message
- The message objectthrowable
- The error object
-
StampedMessage
public StampedMessage(@NonNull @NonNull String message)
Creates a basic INFO level log with the given string message- Parameters:
message
- The string message
-
StampedMessage
public StampedMessage(String message, Throwable throwable)
Creates a log of ERROR level with the given message and Throwable- Parameters:
message
- The message to logthrowable
- The throwable to log
-
StampedMessage
public StampedMessage(@NonNull @NonNull Throwable throwable)
Creates a log of ERROR level with the given Throwable, using its getMessage() as the message- Parameters:
throwable
- The throwable to log
-
-
Method Detail
-
builder
public static StampedMessage.Builder builder()
Constructs a new, emptyStampedMessage.Builder
- Returns:
- The builder
-
builder
public static StampedMessage.Builder builder(StampedMessage copy)
Constructs a builder from an existingStampedMessage
- Parameters:
copy
- The item to copy- Returns:
- The builder object
-
getException
public Throwable getException()
Gets the exception associated with this LogMessage- Returns:
- The exception, or null
-
getLevel
public LogLevel getLevel()
Gets the log level associated with this LogMessage- Returns:
- The log level, never null
-
getMessage
public String getMessage()
Gets the log message- Returns:
- The log message
-
getThread
public String getThread()
Returns the thread associated with this- Returns:
- The thread associated with this message
-
getTimestamp
public long getTimestamp()
Gets the millisecond timestamp when this object was created- Returns:
- The millisecond timestamp of creation
-
isDebug
public boolean isDebug()
Returns true if the log level of this message is exactly DEBUG
-
isError
public boolean isError()
Returns true if the log level of this message is exactly ERROR
-
isInfo
public boolean isInfo()
Returns true if the log level of this message is exactly INFO
-
isInfoOrHigher
public boolean isInfoOrHigher()
Returns true if the log level of this message is INFO, WARN, or ERROR
-
isWarning
public boolean isWarning()
Returns true if the log level of this message is WARN
-
isWarningOrHigher
public boolean isWarningOrHigher()
Returns true if the log level of this message is WARN or ERROR
-
toMap
public Map<String,String> toMap()
Transforms this object to a Map of strings, suitable for passing to a client as JSON or XML.This map will contain the following keys:
- ‘timestamp’: The value of
getTimestamp()
converted to a string - ‘formattedDate’: The value of
getTimestamp()
, formatted usingDateTimeFormatter.ISO_INSTANT
- ‘message’: The message, exactly as passed to this class
- ‘level’: The string name of the
LogLevel
, e.g., ‘DEBUG’ - ‘exception’: If present, the output of
Throwable.printStackTrace(PrintWriter)
The ‘exception’ key will be missing if this object does not return a value for
getException()
.- Returns:
- This object as a Map
- ‘timestamp’: The value of
-
-