Source of file TestHandler.php
Size: 3,056 Bytes - Last Modified: 2013-04-23T12:09:48+02:00
/home/theseer/Downloads/Symfony/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 | <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Logger; /** * Used for testing purposes. * * It records all records and gives you access to them for verification. * * @author Jordi Boggiano <j.boggiano@seld.be> */ class TestHandler extends AbstractProcessingHandler { protected $records = array(); protected $recordsByLevel = array(); public function getRecords() { return $this->records; } public function hasEmergency($record) { return $this->hasRecord($record, Logger::EMERGENCY); } public function hasAlert($record) { return $this->hasRecord($record, Logger::ALERT); } public function hasCritical($record) { return $this->hasRecord($record, Logger::CRITICAL); } public function hasError($record) { return $this->hasRecord($record, Logger::ERROR); } public function hasWarning($record) { return $this->hasRecord($record, Logger::WARNING); } public function hasNotice($record) { return $this->hasRecord($record, Logger::NOTICE); } public function hasInfo($record) { return $this->hasRecord($record, Logger::INFO); } public function hasDebug($record) { return $this->hasRecord($record, Logger::DEBUG); } public function hasEmergencyRecords() { return isset($this->recordsByLevel[Logger::EMERGENCY]); } public function hasAlertRecords() { return isset($this->recordsByLevel[Logger::ALERT]); } public function hasCriticalRecords() { return isset($this->recordsByLevel[Logger::CRITICAL]); } public function hasErrorRecords() { return isset($this->recordsByLevel[Logger::ERROR]); } public function hasWarningRecords() { return isset($this->recordsByLevel[Logger::WARNING]); } public function hasNoticeRecords() { return isset($this->recordsByLevel[Logger::NOTICE]); } public function hasInfoRecords() { return isset($this->recordsByLevel[Logger::INFO]); } public function hasDebugRecords() { return isset($this->recordsByLevel[Logger::DEBUG]); } protected function hasRecord($record, $level) { if (!isset($this->recordsByLevel[$level])) { return false; } if (is_array($record)) { $record = $record['message']; } foreach ($this->recordsByLevel[$level] as $rec) { if ($rec['message'] === $record) { return true; } } return false; } /** * {@inheritdoc} */ protected function write(array $record) { $this->recordsByLevel[$record['level']][] = $record; $this->records[] = $record; } } |