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