cz.cuni.amis.pogamut.base.utils.logging.marks
Class LogEventMark

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.logging.marks.LogEventMark
All Implemented Interfaces:
java.io.Serializable

public class LogEventMark
extends java.lang.Object
implements java.io.Serializable

DO NOT USE THIS CLASS!! Use methods in LogCategory to add events to the log.

This class is special parameter of the LogRecord that means some kind of event has happend to the agent. The handler of log records can do some nifty stuff when he finds this object as parameter of LogRecord, like showing in some GUI.

Under normal circumstances, you create new mark using one of create* methods, pass it as parameter of some log message, it gets transfered (probably through JMX) to some handler on the other side (in our particular case to Netbeans plugin and timeline), where some handler will look for LogRecords with this object as one of parameters and when it finds it, it shows the mark in some GUI. // create an event that with text "Text of event for GUI" that will be // shown for duration of 2 seconds. logger.info("Text of event for text logger" , new Object[]{LogEventMark.createFixedLengthEvent(Level.INFO, "Text of event for GUI", null, 2000)});

See Also:
LogMapMark, Serialized Form

Nested Class Summary
static class LogEventMark.Type
          Type of LogEventMark.
 
Method Summary
static LogEventMark createFixedLengthEvent(java.util.logging.Level level, java.lang.String text, long duration)
          Create log event that will last for some time.
static LogEventMark createSingleLengthEvent(java.util.logging.Level level, java.lang.String text)
          Create single event.
static LogEventMark createVariableLengthEvent(java.util.logging.Level level, java.lang.String text)
          Create log event that will last until notified it should stop.
 boolean equals(java.lang.Object otherObject)
           
 long getDuration()
           
 LogEventMark getEndMark()
          Get ending mark for variable length event.
 int getId()
          Get unique id of event.
 java.util.logging.Level getLevel()
          What is level of this event?
 java.lang.String getText()
           
 long getTime()
           
 LogEventMark.Type getType()
           
 int hashCode()
           
 java.lang.String toString()
          Get human readable representation of LogEventMark.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

createSingleLengthEvent

public static LogEventMark createSingleLengthEvent(java.util.logging.Level level,
                                                   java.lang.String text)
Create single event. Such event has no duration.

Parameters:
level - level of log event, should be same as carrying LogRecord.
text - text of single event
Returns:
created single event.

createFixedLengthEvent

public static LogEventMark createFixedLengthEvent(java.util.logging.Level level,
                                                  java.lang.String text,
                                                  long duration)
Create log event that will last for some time.

Parameters:
level - level of log event, should be same as carrying LogRecord.
text - Text of event
duration - how long should event last.

createVariableLengthEvent

public static LogEventMark createVariableLengthEvent(java.util.logging.Level level,
                                                     java.lang.String text)
Create log event that will last until notified it should stop. In order to stop the event, create end mark of event using getEndMark().

Parameters:
level - level of log event, should be same as carrying LogRecord.
text - text of event.
Returns:
created event.

toString

public java.lang.String toString()
Get human readable representation of LogEventMark.

Overrides:
toString in class java.lang.Object

getId

public int getId()
Get unique id of event. Start and end marks of variable event have same id, because they mark same event.


getLevel

public java.util.logging.Level getLevel()
What is level of this event?

Returns:
level of event.

getText

public java.lang.String getText()
Returns:
the message of this event

getTime

public long getTime()
Returns:
when does event start

getType

public LogEventMark.Type getType()
Returns:
the type of event

getDuration

public long getDuration()
Returns:
the duration of event. 0 for single event, Integer.MAX_VALUE for variable length event

getEndMark

public LogEventMark getEndMark()
Get ending mark for variable length event.

Returns:
if this mark is start mark, create new end mark, if this mark is end mark, return this mark (since we already are end mark).
Throws:
java.lang.IllegalStateException - if type of mark is not start or end.

equals

public boolean equals(java.lang.Object otherObject)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object