func (l *AuditLog) GetSessionEvents(sid session.ID, afterN int) ([]EventFields, error) {
	logFile, err := os.OpenFile(l.sessionLogFn(sid), os.O_RDONLY, 0640)
	if err != nil {
		log.Warn(err)
		// no file found? this means no events have been logged yet
		if os.IsNotExist(err) {
			return nil, nil
		}
		return nil, trace.Wrap(err)
	}
	defer logFile.Close()

	retval := make([]EventFields, 0, 256)

	// read line by line:
	scanner := bufio.NewScanner(logFile)
	for lineNo := 0; scanner.Scan(); lineNo++ {
		if lineNo < afterN {
			continue
		}
		var fields EventFields
		if err = json.Unmarshal(scanner.Bytes(), &fields); err != nil {
			log.Error(err)
			return nil, trace.Wrap(err)
		}
		fields[EventCursor] = lineNo
		retval = append(retval, fields)
	}
	log.Debugf("auditLog.GetSessionEvents() returned %d events", len(retval))
	return retval, nil
}
// Returns all events that happen during a session sorted by time
// (oldest first).
//
// Can be filtered by 'after' (cursor value to return events newer than)
//
// This function is usually used in conjunction with GetSessionReader to
// replay recorded session streams.
Returns all events that happen during a session sorted by time
(oldest first).

Can be filtered by 'after' (cursor value to return events newer than)

This function is usually used in conjunction with GetSessionReader to
replay recorded session streams.
// Returns all events that happen during a session sorted by time // ( oldest first ) . // // Can be filtered by ' after ' ( cursor value to return events newer than ) // // This function is usually used in conjunction with GetSessionReader to // replay recorded session streams .
func (l *AuditLog) GetSessionEvents(sid session.ID, afterN int) ([]EventFields, error) {
	logFile, err := os.OpenFile(l.sessionLogFn(sid), os.O_RDONLY, 0640)
	if err != nil {
		log.Warn(err)
		if os.IsNotExist(err) {
			return nil, nil
		}
		return nil, trace.Wrap(err)
	}
	defer logFile.Close()
	retval := make([]EventFields, 0, 256)
	scanner := bufio.NewScanner(logFile)
	for lineNo := 0; scanner.Scan(); lineNo++ {
		if lineNo < afterN {
			continue
		}
		var fields EventFields
		if err = json.Unmarshal(scanner.Bytes(), &fields); err != nil {
			log.Error(err)
			return nil, trace.Wrap(err)
		}
		fields[EventCursor] = lineNo
		retval = append(retval, fields)
	}
	log.Debugf("auditLog.GetSessionEvents() returned %d events", len(retval))
	return retval, nil
}
func ( l * AuditLog ) GetSessionEvents ( sid session . ID , afterN int ) ( [ ] EventFields , error ) { logFile , err := os . OpenFile ( l . sessionLogFn ( sid ) , os . O_RDONLY , 0640 ) if err != nil { log . Warn ( err ) if os . IsNotExist ( err ) { return nil , nil } return nil , trace . Wrap ( err ) } defer logFile . Close ( ) retval := make ( [ ] EventFields , 0 , 256 ) scanner := bufio . NewScanner ( logFile ) for lineNo := 0 ; scanner . Scan ( ) ; lineNo ++ { if lineNo < afterN { continue } var fields EventFields if err = json . Unmarshal ( scanner . Bytes ( ) , & fields ) ; err != nil { log . Error ( err ) return nil , trace . Wrap ( err ) } fields [ EventCursor ] = lineNo retval = append ( retval , fields ) } log . Debugf ( " " , len ( retval ) ) return retval , nil }
Returns all events that happen during a session sorted by time
(oldest first).
Returns all events that happen during a session sorted by time ( oldest first ) .
// no file found? this means no events have been logged yet // read line by line: