org.openqa.selenium.server.log
Class PerSessionLogHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by org.openqa.selenium.server.log.PerSessionLogHandler

public class PerSessionLogHandler
extends Handler

Handler which keeps in memory the log records per session so that users can retrieve logs per session.


Constructor Summary
PerSessionLogHandler(int capacity, Level minimumLevel, Formatter formatter)
          New handler keeping track of log records per session.
 
Method Summary
 void clearSessionLogRecords(String sessionId)
           
 void clearThreadTempLogs(long threadId)
          Clears the logging events attached to the thread.
 void clearThreadToSessionMapping(long threadId)
           
 void close()
           
 void copyThreadTempLogsToSessionLogs(String sessionId, long threadId)
           
 void flush()
           
 String getLog(String sessionId)
          This returns Selenium Remote Control logs associated with the sessionId.
 void publish(LogRecord record)
           
 void setThreadToSessionMapping(long threadId, String sessionId)
           
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerSessionLogHandler

public PerSessionLogHandler(int capacity,
                            Level minimumLevel,
                            Formatter formatter)
New handler keeping track of log records per session.

Parameters:
minimumLevel - Only keep track of records whose level is equal or greater than minimumLevel.
formatter - Formatter to use when retrieving log messages.
Method Detail

publish

public void publish(LogRecord record)
Specified by:
publish in class Handler

flush

public void flush()
Specified by:
flush in class Handler

close

public void close()
           throws SecurityException
Specified by:
close in class Handler
Throws:
SecurityException

setThreadToSessionMapping

public void setThreadToSessionMapping(long threadId,
                                      String sessionId)

clearThreadToSessionMapping

public void clearThreadToSessionMapping(long threadId)

clearSessionLogRecords

public void clearSessionLogRecords(String sessionId)
                            throws IOException
Throws:
IOException

clearThreadTempLogs

public void clearThreadTempLogs(long threadId)
Clears the logging events attached to the thread. The logging is globally added to the jvm and is effectively used by both classic selenium and WebDriver. WebDriver must call this to avoid leaking memory, even though it is not really used. Ideally we should probably attach the *request* somewhere we could pick it up, so we could attach the pre-session logging to the request instead of the logging. Unfortunately this is no small task.

Parameters:
threadId - The thread to clear for

copyThreadTempLogsToSessionLogs

public void copyThreadTempLogsToSessionLogs(String sessionId,
                                            long threadId)

getLog

public String getLog(String sessionId)
              throws IOException
This returns Selenium Remote Control logs associated with the sessionId.

Parameters:
sessionId - session-id for which the RC logs will be returned.
Returns:
String RC logs for the sessionId
Throws:
IOException


Copyright © 2011. All Rights Reserved.