/** * {@inheritdoc} */ public function report() { $this->debugger->logger()->error($this->getMessage()); if (!$this->config['reporting']['enabled']) { //No need to record anything return; } //Snapshot filename $filename = \Spiral\interpolate($this->config['reporting']['filename'], ['date' => date($this->config['reporting']['dateFormat'], time()), 'exception' => $this->getName()]); //Writing to hard drive $this->files->write($this->config['reporting']['directory'] . '/' . $filename, $this->render(), FilesInterface::RUNTIME, true); $snapshots = $this->files->getFiles($this->config['reporting']['directory']); if (count($snapshots) > $this->config['reporting']['maxSnapshots']) { $oldestSnapshot = ''; $oldestTimestamp = PHP_INT_MAX; foreach ($snapshots as $snapshot) { $snapshotTimestamp = $this->files->time($snapshot); if ($snapshotTimestamp < $oldestTimestamp) { $oldestTimestamp = $snapshotTimestamp; $oldestSnapshot = $snapshot; } } $this->files->delete($oldestSnapshot); } }
/** * Dump value content into specified output. ** * * @param mixed $value * @param int $output * @return null|string */ public function dump($value, $output = self::OUTPUT_ECHO) { if (php_sapi_name() === 'cli' && $output != self::OUTPUT_LOG) { print_r($value); if (is_scalar($value)) { echo "\n"; } return null; } $result = \Spiral\interpolate($this->options['container'], ['dump' => $this->dumpValue($value, '', 0)]); switch ($output) { case self::OUTPUT_ECHO: echo $result; break; case self::OUTPUT_RETURN: return $result; case self::OUTPUT_LOG: if (!empty($this->debugger)) { $this->debugger->logger()->debug(print_r($value, true)); } break; case self::OUTPUT_LOG_NICE: if (!empty($this->debugger)) { $this->debugger->logger()->debug($this->dump($value, self::OUTPUT_RETURN)); } break; } return null; }