FileDocCategorySizeDatePackage
StatefulLoggingHelper.javaAPI DocGlassfish v2 API6982Fri May 04 22:30:50 BST 2007com.sun.appserv.management.helper

StatefulLoggingHelper

public final class StatefulLoggingHelper extends Helper
Helper class for simplifying querying the log files. Unlike {@link LoggingHelper}, state is maintained from call-to-call, which may be helpful in performing repeated queries.

Some combinations of parameters may not be useful; it is up to the caller to ensure reasonable parameters.

A typical use for this helper would be periodic queries for new log records and/or retrieving log records in batches.

since
AppServer 9.0
see
LoggingHelper

Fields Summary
private com.sun.appserv.management.ext.logging.Logging
mLogging
private String
mLogFile
private long
mStartIndex
private Set
mModules
private boolean
mSearchForward
private int
mMaxRecords
private Long
mStartTime
private Long
mStopTime
private String
mLogLevel
private List
mAttrs
Constructors Summary
public StatefulLoggingHelper(com.sun.appserv.management.ext.logging.Logging logging)
Create with default parameters.

		super( logging.getDomainRoot() );
		mLogging    = logging;
		
		mLogFile     = MOST_RECENT_NAME;
		mStartIndex  = FIRST_RECORD;
		mSearchForward  = true;
		mLogLevel       = LOWEST_SUPPORTED_QUERY_LEVEL;
		mModules     = LogModuleNames.ALL_NAMES;
		mMaxRecords  = ALL_RECORDS;
		mStartTime   = null;
		mStopTime    = null;
		mAttrs       = new ArrayList<Attribute>();
	
Methods Summary
public java.util.ListgetAttrs()

 return mAttrs; 
public java.lang.StringgetLogFile()

 return mLogFile; 
public java.lang.StringgetLogLevel()

 return mLogLevel; 
public com.sun.appserv.management.ext.logging.LogginggetLogging()

	    return mLogging;
	
public intgetMaxRecords()

 return mMaxRecords; 
public java.util.SetgetModules()

 return mModules; 
public booleangetSearchForward()

 return mSearchForward; 
public longgetStartIndex()

 return mStartIndex; 
public longgetStartTime()

 return mStartTime; 
public longgetStopTime()

 return mStopTime; 
public com.sun.appserv.management.ext.logging.LogQueryResultquery()
Query for LogRecords based upon the current settings. The startIndex is updated appropriately following the query, depending on the search direction. A subsequent query will begin at the next available index.

	    final Logging   logging = getLogging();
	    assert( logging != null );
	    
        final LogQueryResult result = logging.queryServerLog(
            mLogFile,
            mStartIndex,
            mSearchForward,
            mMaxRecords,
            mStartTime,
            mStopTime,
            mLogLevel,
            mModules,
            mAttrs );
       
       final LogQueryEntry[]    entries = result.getEntries();
       if ( entries.length != 0 )
       {
            // update start index
            if ( mSearchForward )
            {
                mStartIndex    = entries[ entries.length - 1 ].getRecordNumber() + 1;
            }
            else
            {
                mStartIndex = entries[ 0 ].getRecordNumber();
            }
       }
       
       return result;
	
public voidsetAttrs(java.util.List attrs)

	    mAttrs.clear();
	    mAttrs.addAll( attrs );
	
public voidsetLogFile(java.lang.String name)
If the specified log file is different, the startIndex is reset appropriately.

	    if ( ! mLogFile.equals( name ) )
	    {
	        mLogFile    = name;
	        setStartIndex( getSearchForward() ? FIRST_RECORD : LAST_RECORD );
	    }

	
public voidsetLogLevel(java.lang.String logLevel)

	    mLogLevel  = logLevel;
	
public voidsetMaxRecords(int maxRecords)

	    mMaxRecords = maxRecords;
	
public voidsetModule(java.lang.String module)

	    mModules    = GSetUtil.newSet( module );
	
public voidsetModules(java.util.Set modules)

	    mModules    = modules;
	
public voidsetSearchForward(boolean searchForward)

	    mSearchForward  = true;
	
public voidsetStartIndex(int startIndex)

	    mStartIndex    = startIndex;
	
public voidsetStartTime(java.lang.Long startTime)

	    mStartTime  = startTime;
	
public voidsetStopTime(java.lang.Long stopTime)

	    mStopTime  = stopTime;