org.openqa.selenium.server.log
Class DefaultPerSessionLogHandler

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

public class DefaultPerSessionLogHandler
extends PerSessionLogHandler

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


Constructor Summary
DefaultPerSessionLogHandler(int capacity, java.util.logging.Level minimumLevel, java.util.logging.Formatter formatter)
          New handler keeping track of log records per session.
 
Method Summary
 void attachToCurrentThread(java.lang.String sessionId)
           
 void clearThreadTempLogs()
          Clears the logging events attached to the thread.
 void close()
           
 void detachFromCurrentThread()
           
 void flush()
           
 java.lang.String getLog(java.lang.String sessionId)
          This returns Selenium Remote Control logs associated with the sessionId.
 void publish(java.util.logging.LogRecord record)
           
 void removeSessionLogs(java.lang.String sessionId)
           
 void transferThreadTempLogsToSessionLogs(java.lang.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

DefaultPerSessionLogHandler

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

Parameters:
capacity - The capacity
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(java.util.logging.LogRecord record)
Specified by:
publish in class PerSessionLogHandler

flush

public void flush()
Specified by:
flush in class java.util.logging.Handler

close

public void close()
           throws java.lang.SecurityException
Specified by:
close in class java.util.logging.Handler
Throws:
java.lang.SecurityException

attachToCurrentThread

public void attachToCurrentThread(java.lang.String sessionId)
Specified by:
attachToCurrentThread in class PerSessionLogHandler

transferThreadTempLogsToSessionLogs

public void transferThreadTempLogsToSessionLogs(java.lang.String sessionId)
Specified by:
transferThreadTempLogsToSessionLogs in class PerSessionLogHandler

detachFromCurrentThread

public void detachFromCurrentThread()
Specified by:
detachFromCurrentThread in class PerSessionLogHandler

removeSessionLogs

public void removeSessionLogs(java.lang.String sessionId)
Specified by:
removeSessionLogs in class PerSessionLogHandler

clearThreadTempLogs

public void clearThreadTempLogs()
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.

Specified by:
clearThreadTempLogs in class PerSessionLogHandler

getLog

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

Specified by:
getLog in class PerSessionLogHandler
Parameters:
sessionId - session-id for which the RC logs will be returned.
Returns:
String RC logs for the sessionId
Throws:
java.io.IOException - when the elves go bad


Copyright © 2011. All Rights Reserved.