Package com.yahoo.log

Class LogMessage


  • public class LogMessage
    extends Object
    This class implements the common ground log message used by the logserver. A LogMessage is immutable. Note that we have chosen the name LogMessage to avoid confusion with LogRecord which is used in java.util.logging.
    Author:
    Bjorn Borud, bjorncs
    • Method Detail

      • getTimestamp

        public Instant getTimestamp()
      • getHost

        public String getHost()
      • getProcessId

        public long getProcessId()
      • getService

        public String getService()
      • getComponent

        public String getComponent()
      • getLevel

        public Level getLevel()
      • getPayload

        public String getPayload()
      • parseNativeFormat

        public static LogMessage parseNativeFormat​(String msg)
                                            throws InvalidLogFormatException
        Make a log message from the native format of the logging package.
        Parameters:
        msg - The log message
        Returns:
        Returns a LogMessage instance
        Throws:
        InvalidLogFormatException - if the log message can not be parsed, ie. is invalid, we throw this exception.
      • getEvent

        public Event getEvent()
                       throws MalformedEventException
        If the LogMessage was an EVENT then this method can be used to get the Event instance representing the event. The event instance created the first time this method is called and then cached. TODO: make sure this throws exception!
        Returns:
        Returns Event instance if this is an event message and the payload is correctly formatted. Otherwise it will return null.
        Throws:
        MalformedEventException
      • toString

        public String toString()
        Return valid representation of log message.
        Overrides:
        toString in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object