Class LogMessage


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

      Constructors 
      Constructor Description
      LogMessage​(java.lang.Class<?> clazz, java.lang.String method, java.lang.String logMessage, java.lang.String localizeKey)
      Creates a new LogMessage.
      LogMessage​(java.lang.Class<?> clazz, java.lang.String method, java.lang.String logMessage, java.lang.String localizeKey, boolean forceMessagebox)
      Creates a new LogMessage.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addToLog()  
      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.
      java.lang.Class<?> getCausingClass()  
      java.lang.String getLocalizeKey()  
      java.lang.String getMessage()  
      java.lang.String getMethod()  
      java.util.Map<java.lang.String,​java.lang.String> getReplacements()  
      boolean informUser()  
      boolean isForceMessagebox()  
      LogMessage withReplacement​(java.lang.String key, java.lang.String value)
      Convenience method to set a single replacement string.
      LogMessage withReplacements​(java.util.Map<java.lang.String,​java.lang.String> stringsToReplace)
      Adds the map with strings to replace to this instance of LogMessage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LogMessage

        public LogMessage​(java.lang.Class<?> clazz,
                          java.lang.String method,
                          java.lang.String logMessage,
                          java.lang.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​(java.lang.Class<?> clazz,
                          java.lang.String method,
                          java.lang.String logMessage,
                          java.lang.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 Detail

      • withReplacements

        public LogMessage withReplacements​(java.util.Map<java.lang.String,​java.lang.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​(java.lang.String key,
                                          java.lang.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 java.lang.Class<?> getCausingClass()
        Returns:
        name of class the message was caused in
      • getMethod

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

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

        public java.lang.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 java.util.Map<java.lang.String,​java.lang.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.