Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
LoggerDataCollector.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\HttpKernel\DataCollector;
013
014 use Symfony\Component\HttpFoundation\Request;
015 use Symfony\Component\HttpKernel\Debug\ErrorHandler;
016 use Symfony\Component\HttpFoundation\Response;
017 use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
018
019 /**
020 * LogDataCollector.
021 *
022 * @author Fabien Potencier <fabien@symfony.com>
023 */
024 class LoggerDataCollector extends DataCollector
025 {
026 private $logger;
027
028 public function __construct($logger = null)
029 {
030 if (null !== $logger && $logger instanceof DebugLoggerInterface) {
031 $this->logger = $logger;
032 }
033 }
034
035 /**
036 * {@inheritdoc}
037 */
038 public function collect(Request $request, Response $response, \Exception $exception = null)
039 {
040 if (null !== $this->logger) {
041 $this->data = array(
042 'error_count' => $this->logger->countErrors(),
043 'logs' => $this->sanitizeLogs($this->logger->getLogs()),
044 'deprecation_count' => $this->computeDeprecationCount(),
045 );
046 }
047 }
048
049 /**
050 * Gets the called events.
051 *
052 * @return array An array of called events
053 *
054 * @see TraceableEventDispatcherInterface
055 */
056 public function countErrors()
057 {
058 return isset($this->data['error_count']) ? $this->data['error_count'] : 0;
059 }
060
061 /**
062 * Gets the logs.
063 *
064 * @return array An array of logs
065 */
066 public function getLogs()
067 {
068 return isset($this->data['logs']) ? $this->data['logs'] : array();
069 }
070
071 public function countDeprecations()
072 {
073 return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0;
074 }
075
076 /**
077 * {@inheritdoc}
078 */
079 public function getName()
080 {
081 return 'logger';
082 }
083
084 private function sanitizeLogs($logs)
085 {
086 foreach ($logs as $i => $log) {
087 $logs[$i]['context'] = $this->sanitizeContext($log['context']);
088 }
089
090 return $logs;
091 }
092
093 private function sanitizeContext($context)
094 {
095 if (is_array($context)) {
096 foreach ($context as $key => $value) {
097 $context[$key] = $this->sanitizeContext($value);
098 }
099
100 return $context;
101 }
102
103 if (is_resource($context)) {
104 return sprintf('Resource(%s)', get_resource_type($context));
105 }
106
107 if (is_object($context)) {
108 return sprintf('Object(%s)', get_class($context));
109 }
110
111 return $context;
112 }
113
114 private function computeDeprecationCount()
115 {
116 $count = 0;
117 foreach ($this->logger->getLogs() as $log) {
118 if (isset($log['context']['type']) && ErrorHandler::TYPE_DEPRECATION === $log['context']['type']) {
119 $count++;
120 }
121 }
122
123 return $count;
124 }
125 }
126