Package com.saperion.ngc.service
Class LogMessage
java.lang.Object
com.saperion.ngc.service.LogMessage
A log message that is handled by a LogManager.
-
Constructor Summary
ConstructorsConstructorDescriptionLogMessage
(Class<?> clazz, String method, String logMessage, String localizeKey) Creates a new LogMessage.LogMessage
(Class<?> clazz, String method, String logMessage, String localizeKey, boolean forceMessagebox) Creates a new LogMessage. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addToLog()
void
When this method is called on a LogMessage before it gets processed by the log-manager, no messagebox will be shown to the user but the error message will still appear in the log file.Class<?>
boolean
boolean
withReplacement
(String key, String value) Convenience method to set a single replacement string.withReplacements
(Map<String, String> stringsToReplace) Adds the map with strings to replace to this instance of LogMessage.
-
Constructor Details
-
LogMessage
Creates a new LogMessage. If both logMessage and localizeKey is set to null, it is assumed that the original exception was a NullPointerException and "null" will be logged in the log-file.- Parameters:
clazz
- class the message was caused inmethod
- name of method the message was caused inlogMessage
- message text or null if no log entry is neededlocalizeKey
- key of the localized message for the user or null if no message box to the user is needed
-
LogMessage
public LogMessage(Class<?> clazz, String method, String logMessage, String localizeKey, boolean forceMessagebox) Creates a new LogMessage. If both logMessage and localizeKey is set to null, it is assumed that the original exception was a NullPointerException and "null" will be logged in the log-file.- Parameters:
clazz
- class the message was caused inmethod
- name of method the message was caused inlogMessage
- message text or null if no log entry is neededlocalizeKey
- key of the localized message for the user or null if no message box to the user is neededforceMessagebox
- if true, a messagebox will be shown regardless of severity (by default, only error- messages are shown to the user)
-
-
Method Details
-
withReplacements
Adds the map with strings to replace to this instance of LogMessage.- Parameters:
stringsToReplace
- strings to replace- Returns:
- current instance of LogMessage
-
withReplacement
Convenience method to set a single replacement string.- Parameters:
key
- key to replacevalue
- value to replace the key with- Returns:
- current instance of LogMessage
-
getCausingClass
- Returns:
- name of class the message was caused in
-
getMethod
- Returns:
- name of method the message was caused in
-
getMessage
- Returns:
- message text or null if no log entry is needed
-
getLocalizeKey
- Returns:
- key of the localized message or null if no message to the user is needed
-
addToLog
public boolean addToLog()- Returns:
- true if this LogMessage should be added to the log file.
-
informUser
public boolean informUser()- Returns:
- true if this LogMessage should cause a messagebox or an entry in the log view for the user.
-
getReplacements
- Returns:
- map of strings to replace after localization
-
isForceMessagebox
public boolean isForceMessagebox()- Returns:
- if true, a messagebox will be shown regardless of severity
-
disableUserNotification
public void disableUserNotification()When this method is called on a LogMessage before it gets processed by the log-manager, no messagebox will be shown to the user but the error message will still appear in the log file.
-