LogRecordIterator
in package
implements
OuterIterator
The `Aws\CloudTrail\LogRecordIterator` provides an easy way to iterate over log records from log files generated by AWS CloudTrail.
CloudTrail log files contain data about your AWS API calls and are stored in Amazon S3 at a predictable path based on a bucket name, a key prefix, an account ID, a region, and date information. The files are gzipped and contain structured data in JSON format. This class allows you to specify options via its factory methods, including a date range, and emits each log record from any log files that match the provided options.
A log record containing data about an AWS API call is yielded for each iteration on this object.
Interfaces, Classes and Traits
- OuterIterator
Table of Contents
- $logFileIterator : Iterator
- $logFileReader : LogFileReader
- $recordIndex : int
- $records : array<string|int, mixed>
- __construct() : mixed
- current() : array<string|int, mixed>|false
- Returns the current log record as an array.
- forBucket() : LogRecordIterator
- forFile() : LogRecordIterator
- forTrail() : LogRecordIterator
- getInnerIterator() : mixed
- key() : mixed
- next() : mixed
- rewind() : mixed
- valid() : mixed
- loadRecordsFromCurrentLogFile() : bool
- Examines the current file in the `logFileIterator` and attempts to read it and load log records from it using the `logFileReader`. This method expects that items pulled from the iterator will take the form:
Properties
$logFileIterator
private
Iterator
$logFileIterator
$logFileReader
private
LogFileReader
$logFileReader
$recordIndex
private
int
$recordIndex
$records
private
array<string|int, mixed>
$records
Methods
__construct()
public
__construct(LogFileReader $logFileReader, Iterator $logFileIterator) : mixed
Parameters
- $logFileReader : LogFileReader
- $logFileIterator : Iterator
Return values
mixed —current()
Returns the current log record as an array.
public
current() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false —forBucket()
public
static forBucket(S3Client $s3Client, string $s3BucketName[, array<string|int, mixed> $options = [] ]) : LogRecordIterator
Parameters
- $s3Client : S3Client
- $s3BucketName : string
- $options : array<string|int, mixed> = []
Return values
LogRecordIterator —forFile()
public
static forFile(S3Client $s3Client, string $s3BucketName, string $s3ObjectKey) : LogRecordIterator
Parameters
- $s3Client : S3Client
- $s3BucketName : string
- $s3ObjectKey : string
Return values
LogRecordIterator —forTrail()
public
static forTrail(S3Client $s3Client, CloudTrailClient $cloudTrailClient[, array<string|int, mixed> $options = [] ]) : LogRecordIterator
Parameters
- $s3Client : S3Client
- $cloudTrailClient : CloudTrailClient
- $options : array<string|int, mixed> = []
Return values
LogRecordIterator —getInnerIterator()
public
getInnerIterator() : mixed
Return values
mixed —key()
public
key() : mixed
Return values
mixed —next()
public
next() : mixed
Return values
mixed —rewind()
public
rewind() : mixed
Return values
mixed —valid()
public
valid() : mixed
Return values
mixed —loadRecordsFromCurrentLogFile()
Examines the current file in the `logFileIterator` and attempts to read it and load log records from it using the `logFileReader`. This method expects that items pulled from the iterator will take the form:
private
loadRecordsFromCurrentLogFile() : bool
[ 'Bucket' => '...', 'Key' => '...', ]
Return values
bool —Returns true if records were loaded and false if no
records were found