JobHistory
in package
Job History Manager
Provides comprehensive job execution history, logging, and analytics
Table of Contents
Properties
- $historyPath : string
- $maxOutputLength : int
- $retentionDays : int
Methods
- __construct() : mixed
- Constructor
- cleanOldHistory() : int
- Clean old history files
- exportToCsv() : bool
- Export history to CSV
- getGlobalStatistics() : array<string|int, mixed>
- Get global statistics
- getHistoryRange() : array<string|int, mixed>
- Get history for a date range
- getJobHistory() : array<string|int, mixed>
- Get job history
- getJobStatistics() : array<string|int, mixed>
- Get job statistics
- logExecution() : string
- Log job execution
- searchHistory() : array<string|int, mixed>
- Search history
- captureOutput() : array<string|int, mixed>
- Capture job output with length limit
- storeEntry() : void
- Store entry in daily log file
- storeJobHistory() : void
- Store job-specific history
Properties
$historyPath
protected
string
$historyPath
$maxOutputLength
protected
int
$maxOutputLength
= 5000
$retentionDays
protected
int
$retentionDays
= 30
Methods
__construct()
Constructor
public
__construct(string $historyPath[, int $retentionDays = 30 ]) : mixed
Parameters
- $historyPath : string
- $retentionDays : int = 30
cleanOldHistory()
Clean old history files
public
cleanOldHistory() : int
Return values
int —Number of files deleted
exportToCsv()
Export history to CSV
public
exportToCsv(array<string|int, mixed> $history, string $filename) : bool
Parameters
- $history : array<string|int, mixed>
- $filename : string
Return values
boolgetGlobalStatistics()
Get global statistics
public
getGlobalStatistics([int $days = 7 ]) : array<string|int, mixed>
Parameters
- $days : int = 7
Return values
array<string|int, mixed>getHistoryRange()
Get history for a date range
public
getHistoryRange(DateTime $startDate, DateTime $endDate[, string|null $jobId = null ]) : array<string|int, mixed>
Parameters
- $startDate : DateTime
- $endDate : DateTime
- $jobId : string|null = null
-
Filter by job ID
Return values
array<string|int, mixed>getJobHistory()
Get job history
public
getJobHistory(string $jobId[, int $limit = 50 ]) : array<string|int, mixed>
Parameters
- $jobId : string
- $limit : int = 50
Return values
array<string|int, mixed>getJobStatistics()
Get job statistics
public
getJobStatistics(string $jobId[, int $days = 7 ]) : array<string|int, mixed>
Parameters
- $jobId : string
- $days : int = 7
-
Number of days to analyze
Return values
array<string|int, mixed>logExecution()
Log job execution
public
logExecution(Job $job[, array<string|int, mixed> $metadata = [] ]) : string
Parameters
- $job : Job
- $metadata : array<string|int, mixed> = []
-
Additional metadata to store
Return values
string —Log entry ID
searchHistory()
Search history
public
searchHistory(array<string|int, mixed> $criteria) : array<string|int, mixed>
Parameters
- $criteria : array<string|int, mixed>
Return values
array<string|int, mixed>captureOutput()
Capture job output with length limit
protected
captureOutput(Job $job) : array<string|int, mixed>
Parameters
- $job : Job
Return values
array<string|int, mixed>storeEntry()
Store entry in daily log file
protected
storeEntry(array<string|int, mixed> $entry) : void
Parameters
- $entry : array<string|int, mixed>
storeJobHistory()
Store job-specific history
protected
storeJobHistory(string $jobId, array<string|int, mixed> $entry) : void
Parameters
- $jobId : string
- $entry : array<string|int, mixed>