Class LogMessage

java.lang.Object
com.saperion.ngc.service.LogMessage

public class LogMessage extends Object
A log message that is handled by a LogManager.
  • Constructor Details

    • LogMessage

      public LogMessage(Class<?> clazz, String method, String logMessage, String localizeKey)
      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 in
      method - name of method the message was caused in
      logMessage - message text or null if no log entry is needed
      localizeKey - 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 in
      method - name of method the message was caused in
      logMessage - message text or null if no log entry is needed
      localizeKey - key of the localized message for the user or null if no message box to the user is needed
      forceMessagebox - if true, a messagebox will be shown regardless of severity (by default, only error- messages are shown to the user)
  • Method Details

    • withReplacements

      public LogMessage withReplacements(Map<String,String> stringsToReplace)
      Adds the map with strings to replace to this instance of LogMessage.
      Parameters:
      stringsToReplace - strings to replace
      Returns:
      current instance of LogMessage
    • withReplacement

      public LogMessage withReplacement(String key, String value)
      Convenience method to set a single replacement string.
      Parameters:
      key - key to replace
      value - value to replace the key with
      Returns:
      current instance of LogMessage
    • getCausingClass

      public Class<?> getCausingClass()
      Returns:
      name of class the message was caused in
    • getMethod

      public String getMethod()
      Returns:
      name of method the message was caused in
    • getMessage

      public String getMessage()
      Returns:
      message text or null if no log entry is needed
    • getLocalizeKey

      public String 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

      public Map<String,String> 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.