slam / zend-log-extensions
This package is abandoned and no longer maintained.
The author suggests using the slam/laminas-log-extensions package instead.
Slam extensions for zendframework/zend-log
v1.0.1
2018-01-08 16:00 UTC
Requires
- php: ^7.1
- zendframework/zend-log: ^2.9
Requires (Dev)
- phpstan/phpstan: ^0.9.1
- phpstan/phpstan-phpunit: ^0.9.3
- phpunit/phpunit: ^6.5
- slam/php-cs-fixer-extensions: ^1.12
- slam/php-debug-r: ^1.2
- slam/phpstan-extensions: ^1.0
- thecodingmachine/phpstan-strict-rules: ^0.9.0
This package is auto-updated.
Last update: 2020-01-02 14:30:58 UTC
README
Repository abandoned 2019-12-31
This repository has moved to Slamdunk/laminas-log-extensions.
Slam Zend\Log extensions
Extensions for Zend\Log
Installation
Execute:
composer require slam/zend-log-extensions
Usage
The main functionality of this package is the RotateStream writer. PHP cannot handle files larger than 2 GB, so if you log a lot you can end up losing some if you reach this limit.
Slam\Zend\Log\Writer\RotateStream
rotates the write when it reaches ~1.5 GB.
use Slam\Zend\Log\Writer\RotateStream; use Zend\Log\Formatter\Simple; use Zend\Log\Logger; $writer = new RotateStream(__DIR__ . '/log.txt'); $writer->setFormatter(new Simple()); // Do the check everytime, defaults to once every 100000 log entries $writer->setCheckProbability(1); // 10 bytes max file size, defaults to ~1.5 GB $writer->setMaxFileSize(10); $logger = new Logger(); $logger->addWriter($writer); for ($i = 0; $i < 10; ++$i) { $logger->info($i); sleep(1); }
This is what you'll find in the directory:
$ ls log.txt*
log.txt log.txt.1 log.txt.2 log.txt.3 log.txt.4 log.txt.5 log.txt.6 log.txt.7 log.txt.8 log.txt.9
$ cat log.txt.9
2017-09-05T11:08:46+02:00 INFO (6): 8
2017-09-05T11:08:47+02:00 NOTICE (5): LOG ROTATE
$ cat log.txt
2017-09-05T11:08:47+02:00 INFO (6): 9