Plop
A simple logging library for PHP
Plop\Handler\RotatingFile Class Reference

An handler the saves log messages in a file, which is rotated whenever it reaches a certain size. More...

+ Inheritance diagram for Plop\Handler\RotatingFile:

Public Member Functions

 __construct ($filename, $maxBytes=0, $backupCount=0, $mode= 'a', $delay=0)
 
- 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

 doRollover ()
 
 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.
 
 $maxBytes
 The maximum size the log file may reach before being rotated.
 
- 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.
 

Additional Inherited Members

- Static Protected Attributes inherited from Plop\Handler\Stream
static $stderr = null
 A stream referencing STDERR.
 

Detailed Description

An handler the saves log messages in a file, which is rotated whenever it reaches a certain size.

Definition at line 29 of file RotatingFile.php.

Constructor & Destructor Documentation

Plop\Handler\RotatingFile::__construct (   $filename,
  $maxBytes = 0,
  $backupCount = 0,
  $mode = 'a',
  $delay = 0 
)

Construct a new instance of this handler.

Parameters
string$filenameName of the log file to write to.
int$maxBytesThe maximum size the log file may occupy, in bytes.
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.
string$mode(optional) Mode to use when opening the file. Defauts to "at" (append).
bool$delay(optional) Whether to delay the actual opening of the file until the first write. Defaults to false (no delay).
Note
Depending on your installation, values bigger than 1<<31 (2 GB) for the $maxBytes parameter may not work correctly.

Definition at line 69 of file RotatingFile.php.

References Plop\Handler\RotatingFile\$backupCount, Plop\Handler\RotatingFile\$maxBytes, and Plop\Handler\File\$mode.

Member Function Documentation

Plop\Handler\RotatingFile::doRollover ( )
protected

Do the actual file rotation.

Returns
This method does not return any value.

Definition at line 85 of file RotatingFile.php.

References Plop\Handler\File\open().

Plop\Handler\RotatingFile::shouldRollover ( \Plop\RecordInterface  $record)
protected

Definition at line 110 of file RotatingFile.php.

References Plop\HandlerAbstract\format(), and Plop\Handler\File\open().


The documentation for this class was generated from the following file: