Plop
A simple logging library for PHP
|
An handler that writes logs to a file but also handles that file's rotation, based on time. More...
Public Member Functions | |
__construct ($filename, $when= 'h', $interval=1, $backupCount=0, $delay=false, $utc=false) | |
Public Member Functions inherited from Plop\Handler\File | |
__construct ($filename, $mode= 'at', $delay=false) | |
__destruct () | |
Free the resources used by this handler. | |
Public Member Functions inherited from Plop\Handler\Stream | |
__construct ($stream=null) | |
Public Member Functions inherited from Plop\HandlerAbstract | |
__construct (\Plop\FormatterInterface $formatter=null,\Plop\FiltersCollectionAbstract $filters=null) | |
getFilters () | |
getFormatter () | |
handle (\Plop\RecordInterface $record) | |
handleError (\Plop\RecordInterface $record,\Exception $exception) | |
setFilters (\Plop\FiltersCollectionAbstract $filters) | |
setFormatter (\Plop\FormatterInterface $formatter) | |
Protected Member Functions | |
computeRollover ($currentTime) | |
doRollover () | |
getFilesToDelete () | |
getTime () | |
shouldRollover (\Plop\RecordInterface $record) | |
Protected Member Functions inherited from Plop\Handler\RotatingAbstract | |
doRollover () | |
emit (\Plop\RecordInterface $record) | |
shouldRollover (\Plop\RecordInterface $record) | |
Protected Member Functions inherited from Plop\Handler\File | |
close () | |
emit (\Plop\RecordInterface $record) | |
open () | |
Protected Member Functions inherited from Plop\Handler\Stream | |
emit (\Plop\RecordInterface $record) | |
flush () | |
Protected Member Functions inherited from Plop\HandlerAbstract | |
emit (\Plop\RecordInterface $record) | |
format (\Plop\RecordInterface $record) | |
getStderr () | |
Protected Attributes | |
$backupCount | |
Number of backup log files to keep. | |
$dayOfWeek | |
Day of week (0=Monday...6=Sunday) when the log rotation happens. | |
$extMatch | |
A PCRE pattern that matches rotated files. | |
$interval | |
Interval between file rotations. | |
$rolloverAt | |
UNIX timestamp of the next log rotation. | |
$suffix | |
The date format that will be used as a suffix for the log files. | |
$utc | |
Whether the files are named based on UTC time or local time. | |
$when | |
Log rotation specification (eg. 'W' or 'MIDNIGHT'). | |
Protected Attributes inherited from Plop\Handler\File | |
$baseFilename | |
Path to the log file this handler writes to. | |
$mode | |
Opening mode for the log file. | |
Protected Attributes inherited from Plop\Handler\Stream | |
$stream | |
The stream where log messages will be write to. | |
Protected Attributes inherited from Plop\HandlerAbstract | |
$filters | |
An object handling a collection of filters. | |
$formatter | |
Formatter object to use for this handler. | |
Static Protected Attributes | |
static | $dayNames |
The names of days in English, starting with Monday. More... | |
Static Protected Attributes inherited from Plop\Handler\Stream | |
static | $stderr = null |
A stream referencing STDERR. | |
An handler that writes logs to a file but also handles that file's rotation, based on time.
Definition at line 29 of file TimedRotatingFile.php.
Plop\Handler\TimedRotatingFile::__construct | ( | $filename, | |
$when = 'h' , |
|||
$interval = 1 , |
|||
$backupCount = 0 , |
|||
$delay = false , |
|||
$utc = false |
|||
) |
Construct a new instance of this handler.
string | $filename | Name of the log file to write to. |
string | $when | (optional) A log rotation specification, which acts as a multiplier for the $interval parameter. The default value is "h". Valid (case-insensitive) values include
|
int | $interval | (optional)-The interval at which log rotations happen. See also the documentation for the $when parameter for more information on how the two parameters interact with each other. The default for both this parameter and $when means that the log rotation will take place every hour. |
int | $backupCount | (optional) Specifies how many backup logs are kept alongside the current log file. Backup logs are named after the date and time at which they were created. The exact format depends on the value of the $when parameter. The default value is 0, which disables deletion of old backups. |
bool | $delay | (optional) Whether to delay the actual opening of the file until the first write. Defaults to false (no delay). |
bool | $utc | Whether the dates and times used in the backups' name should use UTC (true) or local time (false). |
Definition at line 118 of file TimedRotatingFile.php.
References Plop\Handler\TimedRotatingFile\$backupCount, Plop\Handler\TimedRotatingFile\$interval, Plop\Handler\TimedRotatingFile\$utc, Plop\Handler\TimedRotatingFile\$when, Plop\Handler\TimedRotatingFile\computeRollover(), and Plop\Handler\TimedRotatingFile\getTime().
|
protected |
Determine when the next log rotation should take place.
int | $currentTime | Current time, as a UNIX timestamp. |
int | UNIX timestamp for the next log rotation. |
Definition at line 204 of file TimedRotatingFile.php.
References Plop\Handler\TimedRotatingFile\$interval.
Referenced by Plop\Handler\TimedRotatingFile\__construct(), and Plop\Handler\TimedRotatingFile\doRollover().
|
protected |
Do the actual file rotation.
Definition at line 278 of file TimedRotatingFile.php.
References Plop\Handler\TimedRotatingFile\$interval, Plop\Handler\TimedRotatingFile\computeRollover(), Plop\Handler\TimedRotatingFile\getFilesToDelete(), and Plop\Handler\File\open().
|
protected |
Return a list of old log files to delete.
array | List of old log files to delete. |
Definition at line 245 of file TimedRotatingFile.php.
References Plop\Handler\TimedRotatingFile\$suffix.
Referenced by Plop\Handler\TimedRotatingFile\doRollover().
|
protected |
Return the current time, as a UNIX timestamp.
int | Current time, as a UNIX timestamp. |
Definition at line 228 of file TimedRotatingFile.php.
Referenced by Plop\Handler\TimedRotatingFile\__construct(), and Plop\Handler\TimedRotatingFile\shouldRollover().
|
protected |
Definition at line 234 of file TimedRotatingFile.php.
References Plop\Handler\TimedRotatingFile\getTime().
|
staticprotected |
The names of days in English, starting with Monday.
Definition at line 56 of file TimedRotatingFile.php.