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
-
-
Constructor Summary
Constructors Constructor Description StampedMessage(LogLevel level, String message)
Creates a basic log of the given level with the given string messageStampedMessage(LogLevel level, String message, Throwable exception)
Full constructor taking a level, a message, and an exception.StampedMessage(String message)
Creates a basic INFO level log with the given string messageStampedMessage(String message, Throwable throwable)
Creates a log of ERROR level with the given message and ThrowableStampedMessage(Throwable throwable)
Creates a log of ERROR level with the given Throwable, using its getMessage() as the messageStampedMessage(sailpoint.tools.Message message)
Creates a log from a SailPoint Message objectStampedMessage(sailpoint.tools.Message message, Throwable throwable)
Creates a log from a SailPoint Message object and a throwable
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
getException()
Gets the exception associated with this LogMessageLogLevel
getLevel()
Gets the log level associated with this LogMessageString
getMessage()
Gets the log messagelong
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(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(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(sailpoint.tools.Message message)
Creates a log from a SailPoint Message object- Parameters:
message
- A Sailpoint message
-
StampedMessage
public StampedMessage(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(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(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
-
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
-
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
-
-