Package com.yahoo.log
Class LogMessage
- java.lang.Object
-
- com.yahoo.log.LogMessage
-
public class LogMessage extends java.lang.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
getComponent()
Event
getEvent()
If the LogMessage was an EVENT then this method can be used to get the Event instance representing the event.java.lang.String
getHost()
java.util.logging.Level
getLevel()
java.lang.String
getPayload()
long
getProcessId()
java.lang.String
getService()
java.util.OptionalLong
getThreadId()
java.lang.String
getThreadProcess()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetProcessId()
/getThreadId()
long
getTime()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTimestamp()
long
getTimeInSeconds()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTimestamp()
java.time.Instant
getTimestamp()
int
hashCode()
static LogMessage
of(java.time.Instant time, java.lang.String host, long processId, long threadId, java.lang.String service, java.lang.String component, java.util.logging.Level level, java.lang.String payload)
static LogMessage
parseNativeFormat(java.lang.String msg)
Make a log message from the native format of the logging package.java.lang.String
toString()
Return valid representation of log message.
-
-
-
Method Detail
-
of
public static LogMessage of(java.time.Instant time, java.lang.String host, long processId, long threadId, java.lang.String service, java.lang.String component, java.util.logging.Level level, java.lang.String payload)
-
getTimestamp
public java.time.Instant getTimestamp()
-
getTime
@Deprecated(since="7", forRemoval=true) public long getTime()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTimestamp()
-
getTimeInSeconds
@Deprecated(since="7", forRemoval=true) public long getTimeInSeconds()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTimestamp()
-
getHost
public java.lang.String getHost()
-
getProcessId
public long getProcessId()
-
getThreadId
public java.util.OptionalLong getThreadId()
-
getThreadProcess
@Deprecated(since="7", forRemoval=true) public java.lang.String getThreadProcess()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetProcessId()
/getThreadId()
-
getService
public java.lang.String getService()
-
getComponent
public java.lang.String getComponent()
-
getLevel
public java.util.logging.Level getLevel()
-
getPayload
public java.lang.String getPayload()
-
parseNativeFormat
public static LogMessage parseNativeFormat(java.lang.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 java.lang.String toString()
Return valid representation of log message.- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-