Class LogEntry
- java.lang.Object
-
- com.gurock.smartinspect.packets.Packet
-
- com.gurock.smartinspect.packets.logentry.LogEntry
-
public final class LogEntry extends Packet
Represents the Log Entry packet type which is used for nearly all logging methods in the Session class.A Log Entry is the most important packet available in the SmartInspect concept. It is used for almost all logging methods in the Session class, like, for example, Session.logMessage, Session.logObject or Session.logSql.
A Log Entry has several properties which describe its creation context (like a thread ID, timestamp or hostname) and other properties which specify the way the Console interprets this packet (like the viewer ID or the background color). Furthermore a Log Entry contains the actual data which will be displayed in the Console.
This class is not guaranteed to be threadsafe. However, instances of this class will normally only be used in the context of a single thread.
-
-
Field Summary
-
Fields inherited from class com.gurock.smartinspect.packets.Packet
PACKET_HEADER
-
-
Constructor Summary
Constructors Constructor Description LogEntry()Overloaded.LogEntry(LogEntryType logEntryType, ViewerId viewerId)Overloaded.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAppName()Returns the application name of this Log Entry.ColorgetColor()Returns the background color of this Log Entry.byte[]getData()Returns the optional data block of the Log Entry.StringgetHostName()Returns the hostname of this Log Entry.LogEntryTypegetLogEntryType()Returns the type of this Log Entry.PacketTypegetPacketType()Overridden.intgetProcessId()Returns the process ID of this LogEntry object.StringgetSessionName()The session name of a Log Entry is normally set to the name of the session which sent this Log Entry.intgetSize()Overridden.intgetThreadId()Returns the thread ID of this LogEntry object.longgetTimestamp()Returns the timestamp of this LogEntry object.StringgetTitle()Returns the title of this Log Entry.ViewerIdgetViewerId()Returns the viewer ID of this Log Entry.voidsetAppName(String appName)Sets the application name of this Log Entry.voidsetColor(Color color)Sets the background color of this Log Entry.voidsetData(byte[] data)Sets the optional data block of this Log Entry.voidsetHostName(String hostName)Sets the hostname of this Log Entry.voidsetLogEntryType(LogEntryType logEntryType)Sets the type of this Log Entry.voidsetProcessId(int processId)Sets the process ID of this LogEntry object.voidsetSessionName(String sessionName)Sets the session name of the Log Entry.voidsetThreadId(int threadId)Sets the thread ID of this LogEntry object.voidsetTimestamp(long timestamp)Sets the timestamp of this LogEntry object.voidsetTitle(String title)Sets the title of this Log Entry.voidsetViewerId(ViewerId viewerId)Sets the viewer ID of this Entry.-
Methods inherited from class com.gurock.smartinspect.packets.Packet
getBytes, getLevel, getStringSize, isThreadSafe, lock, setBytes, setLevel, setThreadSafe, unlock
-
-
-
-
Constructor Detail
-
LogEntry
public LogEntry()
Overloaded. Creates and initializes a LogEntry instance.
-
LogEntry
public LogEntry(LogEntryType logEntryType, ViewerId viewerId)
Overloaded. Creates and initializes a LogEntry instance with a custom log entry type and custom viewer ID.If the logEntryType or viewerId argument is a null reference a NullPointerException will be thrown.
- Parameters:
logEntryType- The type of the new Log Entry describes the way the Console interprets this packet. Please see the LogEntryType type for more information. Not allowed to be nullviewerId- The viewer ID of the new Log Entry describes which viewer should be used in the Console when displaying the data of this Log Entry. Please see ViewerId for more information. Not allowed to be null- Throws:
NullPointerException- if the logEntryType or viewerId argument is null
-
-
Method Detail
-
getSize
public int getSize()
Overridden. Returns the total occupied memory size of this Log Entry packet.The total occupied memory size of this Log Entry is the size of memory occupied by all strings, the optional data block and any internal data structures of this Log Entry.
-
getPacketType
public PacketType getPacketType()
Overridden. Returns PacketType.LogEntry.- Specified by:
getPacketTypein classPacket- Returns:
- Just PacketType.LogEntry. For a complete list of available packet types, please have a look at the documentation of the PacketType type
-
getTitle
public String getTitle()
Returns the title of this Log Entry. This method can return null if this Log Entry does not contain a title. If this is the case, the title of this Log Entry will be empty in the SmartInspect Console.- Returns:
- The title of the Log Entry or null if the title has not been set
-
setTitle
public void setTitle(String title)
Sets the title of this Log Entry.The title of this Log Entry will be empty in the SmartInspect Console when this method gets a null reference as argument.
- Parameters:
title- The new title of this Log Entry. Can be null
-
getSessionName
public String getSessionName()
The session name of a Log Entry is normally set to the name of the session which sent this Log Entry.This method can return null if this Log Entry does not contain a session name. If this is the case, the session name will be empty in the SmartInspect Console.
Returns the session name of the Log Entry.
- Returns:
- The session name of the Log Entry or null if the session name has not been set
-
setSessionName
public void setSessionName(String sessionName)
Sets the session name of the Log Entry.The session name of this Log Entry will be empty in the SmartInspect Console when this method gets a null reference as argument.
- Parameters:
sessionName- The new session name of this Log Entry. Can be null
-
getHostName
public String getHostName()
Returns the hostname of this Log Entry.The hostname of a Log Entry is usually set to the name of the machine this Log Entry is sent from. This method can return null if this Log Entry does not contain a hostname. If this is the case, the hostname will be empty in the SmartInspect Console.
- Returns:
- The hostname of the Log Entry or null if the hostname has not been set
-
setHostName
public void setHostName(String hostName)
Sets the hostname of this Log Entry.The hostname of this Log Entry will be empty in the SmartInspect Console when this method gets a null reference as argument.
- Parameters:
hostName- The new hostname of this Log Entry. Can be null
-
getAppName
public String getAppName()
Returns the application name of this Log Entry.The application name of a Log Entry is usually set to the name of the application this Log Entry is created in.
This method can return null if this Log Entry does not contain an application name. If this is the case, the application name will be empty in the SmartInspect Console.
- Returns:
- The application name of the Log Entry or null if the application name has not been set
-
setAppName
public void setAppName(String appName)
Sets the application name of this Log Entry.The application name of this Log Entry will be empty in the SmartInspect Console when this method gets a null reference as argument.
- Parameters:
appName- The new application name of this Log Entry. Can be null
-
getLogEntryType
public LogEntryType getLogEntryType()
Returns the type of this Log Entry.- Returns:
- The type of this Log Entry. It describes the way the Console interprets this packet. Please see the LogEntryType enum for more information
-
setLogEntryType
public void setLogEntryType(LogEntryType logEntryType)
Sets the type of this Log Entry.The type of this Log Entry describes the way the Console interprets this packet. Please see the LogEntryType enum for more information. If the logEntryType argument is a null reference a NullPointerException will be thrown.
- Parameters:
logEntryType- The new type of this Log Entry. Not allowed to be null- Throws:
NullPointerException- If the logEntryType argument is null
-
getViewerId
public ViewerId getViewerId()
Returns the viewer ID of this Log Entry.- Returns:
- The viewer ID of the Log Entry. It describes which viewer should be used in the Console when displaying the data of this Log Entry. Please see the ViewerId enum for more information
-
setViewerId
public void setViewerId(ViewerId viewerId)
Sets the viewer ID of this Entry.The viewer ID of the Log Entry describes which viewer should be used in the Console when displaying the data of this Log Entry. Please see the ViewerId enum for more information.
If the viewerId argument is a null reference a NullPointerException will be thrown.
- Parameters:
viewerId- The new viewer ID of this Log Entry. Not allowed to be null- Throws:
NullPointerException- if the viewerId argument is null
-
getColor
public Color getColor()
Returns the background color of this Log Entry. The background color of a Log Entry is normally set to the color of the session which sent this Log Entry. This method can return null if this Log Entry uses the default background color in the SmartInspect Console.- Returns:
- The background color of the Log Entry or null if this Log
-
setColor
public void setColor(Color color)
Sets the background color of this Log Entry.This Log Entry uses the default background color in the SmartInspect Console when this method gets a null reference as argument.
- Parameters:
color- The new background color of this Log Entry. Can be null
-
getData
public byte[] getData()
Returns the optional data block of the Log Entry.This method can return null if this Log Entry does not contain additional data.
Important: Treat the returned array as read-only. This means, modifying this array in any way is not supported.
- Returns:
- The optional data block of the Log Entry or null if this Log Entry does not contain additional data
-
setData
public void setData(byte[] data)
Sets the optional data block of this Log Entry.Because of the fact that the data block of a Log Entry is optional, it is allowed to pass a null reference.
Important: Treat the passed array as read-only. This means, modifying this array in any way after passing it to this method is not supported.
- Parameters:
data- The new data block of this Log Entry. Can be null
-
getTimestamp
public long getTimestamp()
Returns the timestamp of this LogEntry object.- Returns:
- The creation time of this Log Entry object as returned by the SmartInspect.now() method.
-
setTimestamp
public void setTimestamp(long timestamp)
Sets the timestamp of this LogEntry object.- Parameters:
timestamp- The new timestamp of this LogEntry object. The passed value should represent the local date and time in microseconds since January 1, 1970. See SmartInspect.now() for more information.
-
getProcessId
public int getProcessId()
Returns the process ID of this LogEntry object.- Returns:
- The ID of the process this Log Entry object was created in
-
setProcessId
public void setProcessId(int processId)
Sets the process ID of this LogEntry object.- Parameters:
processId- The new process ID of this LogEntry object
-
getThreadId
public int getThreadId()
Returns the thread ID of this LogEntry object.- Overrides:
getThreadIdin classPacket- Returns:
- The ID of the thread this Log Entry object was created in
-
setThreadId
public void setThreadId(int threadId)
Sets the thread ID of this LogEntry object.- Parameters:
threadId- The new thread ID of this Log Entry object
-
-