Class MessageLog

java.lang.Object
ghidra.app.util.importer.MessageLog
Direct Known Subclasses:
XmlMessageLog

public class MessageLog extends Object
A simple class to handle logging messages and exceptions. A maximum message count size constraint can be set to clip messages after a certain number, but still keep incrementing a running total.

In addition to logging messages, clients can also set a status message. This message may later used as the primary error message when reporting to the user.

  • Constructor Details

    • MessageLog

      public MessageLog()
  • Method Details

    • copyFrom

      public void copyFrom(MessageLog log)
      Copies the contents of one message log into this one
      Parameters:
      log - the log to copy from
    • appendMsg

      public void appendMsg(String message)
      Appends the message to the log
      Parameters:
      message - the message
    • appendMsg

      public void appendMsg(String originator, String message)
      Appends the message to the log
      Parameters:
      originator - the originator of the message
      message - the message
    • appendMsg

      public void appendMsg(int lineNum, String message)
      Appends the message and line number to the log
      Parameters:
      lineNum - the line number that generated the message
      message - the message
    • appendException

      public void appendException(Throwable t)
      Appends the exception to the log
      Parameters:
      t - the exception to append to the log
    • error

      @Deprecated public void error(String originator, String message)
      Deprecated.
      Readable method for appending error messages to the log.

      Currently does nothing different than appendMsg(String, String).

      Parameters:
      originator - the originator of the message
      message - the message
    • hasMessages

      public boolean hasMessages()
      Returns true if this log has messages
      Returns:
      true if this log has messages
    • clear

      public void clear()
      Clears all messages from this log and resets the count
    • setStatus

      public void setStatus(String status)
      Stores a status message that can be used elsewhere (i.e., populate warning dialogs)
      Parameters:
      status - the status message
    • clearStatus

      public void clearStatus()
      Clear status message
    • getStatus

      public String getStatus()
      Returns a stored status message
      Returns:
      stored status message
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • write

      public void write(Class<?> owner, String messageHeader)
      Writes this log's contents to the application log
      Parameters:
      owner - the owning class whose name will appear in the log message
      messageHeader - the message header that will appear before the log messages