Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 |
Logger.php
001 <?php
002
003 /**
004 * @package s9e\TextFormatter
005 * @copyright Copyright (c) 2010-2022 The s9e authors
006 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
007 */
008 namespace s9e\TextFormatter\Parser;
009
010 use InvalidArgumentException;
011 use s9e\TextFormatter\Parser;
012
013 class Logger
014 {
015 /**
016 * @var string Name of the attribute being processed
017 */
018 protected $attrName;
019
020 /**
021 * @var array Log entries in the form [[<type>,<msg>,<context>]]
022 */
023 protected $logs = [];
024
025 /**
026 * @var Tag Tag being processed
027 */
028 protected $tag;
029
030 /**
031 * Add a log entry
032 *
033 * @param string $type
034 * @param string $msg
035 * @param array $context
036 * @return void
037 */
038 protected function add($type, $msg, array $context)
039 {
040 if (!isset($context['attrName']) && isset($this->attrName))
041 {
042 $context['attrName'] = $this->attrName;
043 }
044
045 if (!isset($context['tag']) && isset($this->tag))
046 {
047 $context['tag'] = $this->tag;
048 }
049
050 $this->logs[] = [$type, $msg, $context];
051 }
052
053 /**
054 * Clear the log
055 *
056 * @return void
057 */
058 public function clear()
059 {
060 $this->logs = [];
061 $this->unsetAttribute();
062 $this->unsetTag();
063 }
064
065 /**
066 * Return the logs
067 *
068 * @return array
069 */
070 public function getLogs()
071 {
072 return $this->logs;
073 }
074
075 /**
076 * Record the name of the attribute being processed
077 *
078 * @param string $attrName
079 * @return void
080 */
081 public function setAttribute($attrName)
082 {
083 $this->attrName = $attrName;
084 }
085
086 /**
087 * Record the tag being processed
088 *
089 * @param Tag $tag
090 * @return void
091 */
092 public function setTag(Tag $tag)
093 {
094 $this->tag = $tag;
095 }
096
097 /**
098 * Unset the name of the attribute being processed
099 *
100 * @return void
101 */
102 public function unsetAttribute()
103 {
104 unset($this->attrName);
105 }
106
107 /**
108 * Unset the tag being processed
109 *
110 * @return void
111 */
112 public function unsetTag()
113 {
114 unset($this->tag);
115 }
116
117 //==========================================================================
118 // Log levels
119 //==========================================================================
120
121 /**
122 * Add a "debug" type log entry
123 *
124 * @param string $msg Log message
125 * @param array $context
126 * @return void
127 */
128 public function debug($msg, array $context = [])
129 {
130 $this->add('debug', $msg, $context);
131 }
132
133 /**
134 * Add an "err" type log entry
135 *
136 * @param string $msg Log message
137 * @param array $context
138 * @return void
139 */
140 public function err($msg, array $context = [])
141 {
142 $this->add('err', $msg, $context);
143 }
144
145 /**
146 * Add an "info" type log entry
147 *
148 * @param string $msg Log message
149 * @param array $context
150 * @return void
151 */
152 public function info($msg, array $context = [])
153 {
154 $this->add('info', $msg, $context);
155 }
156
157 /**
158 * Add a "warn" type log entry
159 *
160 * @param string $msg Log message
161 * @param array $context
162 * @return void
163 */
164 public function warn($msg, array $context = [])
165 {
166 $this->add('warn', $msg, $context);
167 }
168 }