private OutputStream checkLogFile(String basename,long maxRecords,boolean force) throws IOException {
  final OutputStream newStream;
synchronized (this) {
    if ((force == false) && (logCount < maxRecords))     return logStream;
    final OutputStream oldStream=logStream;
    if (oldStream != null) {
      oldStream.flush();
      oldStream.close();
    }
    final File newFile=(basename == null) ? null : createNewLogFile(basename);
    newStream=(newFile == null) ? null : new FileOutputStream(newFile,true);
    logStream=newStream;
    logFile=newFile;
    fileCapacity=maxRecords;
    logCount=0;
  }
  sendNotification(new Notification(LOG_FILE_CHANGED,objectName,getNextSeqNumber(),basename));
  return newStream;
}

private OutputStream checkLogFile ( String basename , long maxRecords , boolean force ) throws IOException { final OutputStream newStream ; synchronized ( this ) { if ( ( force == false ) && ( logCount < maxRecords ) ) return logStream ; final OutputStream oldStream = logStream ; if ( oldStream != null ) { oldStream . flush ( ) ; oldStream . close ( ) ; } final File newFile = ( basename == null ) ? null : createNewLogFile ( basename ) ; newStream = ( newFile == null ) ? null : new FileOutputStream ( newFile , true ) ; logStream = newStream ; logFile = newFile ; fileCapacity = maxRecords ; logCount = 0 ; } sendNotification ( new Notification ( LOG_FILE_CHANGED , objectName , getNextSeqNumber ( ) , basename ) ) ; return newStream ; }
check whether a new log file should be created . if a new file needs to be created , creates it , renaming previously existing file by appending ' ~ ' to its name . also reset the log count and file capacity . sends a notification indicating that the log file was changed . returns the new log stream ; creation of a new file can be forced by passing force = true .
