@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\log\driver; |
14 | 14 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $msg = var_export($msg, true); |
81 | 81 | } |
82 | 82 | |
83 | - $info[$type][] = $this->config['json'] ? $msg : '[ ' . $type . ' ] ' . $msg; |
|
83 | + $info[$type][] = $this->config['json'] ? $msg : '[ '.$type.' ] '.$msg; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | if (!$this->config['json'] && (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level']))) { |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | protected function getMasterLogFile(): string |
139 | 139 | { |
140 | 140 | if (empty($this->config['path'])) { |
141 | - $this->config['path'] = $this->app->getRuntimePath() . 'log' . DIRECTORY_SEPARATOR; |
|
141 | + $this->config['path'] = $this->app->getRuntimePath().'log'.DIRECTORY_SEPARATOR; |
|
142 | 142 | } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
143 | 143 | $this->config['path'] .= DIRECTORY_SEPARATOR; |
144 | 144 | } |
145 | 145 | |
146 | 146 | if ($this->config['max_files']) { |
147 | - $files = glob($this->config['path'] . '*.log'); |
|
147 | + $files = glob($this->config['path'].'*.log'); |
|
148 | 148 | |
149 | 149 | try { |
150 | 150 | if (count($files) > $this->config['max_files']) { |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | if ($this->config['single']) { |
159 | 159 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
160 | 160 | $cli = $this->isCli ? '_cli' : ''; |
161 | - $destination = $this->config['path'] . $name . $cli . '.log'; |
|
161 | + $destination = $this->config['path'].$name.$cli.'.log'; |
|
162 | 162 | } else { |
163 | 163 | $cli = $this->isCli ? '_cli' : ''; |
164 | 164 | |
165 | 165 | if ($this->config['max_files']) { |
166 | - $filename = date('Ymd') . $cli . '.log'; |
|
166 | + $filename = date('Ymd').$cli.'.log'; |
|
167 | 167 | } else { |
168 | - $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . $cli . '.log'; |
|
168 | + $filename = date('Ym').DIRECTORY_SEPARATOR.date('d').$cli.'.log'; |
|
169 | 169 | } |
170 | 170 | |
171 | - $destination = $this->config['path'] . $filename; |
|
171 | + $destination = $this->config['path'].$filename; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $destination; |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | if ($this->config['single']) { |
189 | 189 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
190 | 190 | |
191 | - $name .= '_' . $type; |
|
191 | + $name .= '_'.$type; |
|
192 | 192 | } elseif ($this->config['max_files']) { |
193 | - $name = date('Ymd') . '_' . $type . $cli; |
|
193 | + $name = date('Ymd').'_'.$type.$cli; |
|
194 | 194 | } else { |
195 | - $name = date('d') . '_' . $type . $cli; |
|
195 | + $name = date('d').'_'.$type.$cli; |
|
196 | 196 | } |
197 | 197 | |
198 | - return $path . DIRECTORY_SEPARATOR . $name . '.log'; |
|
198 | + return $path.DIRECTORY_SEPARATOR.$name.'.log'; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { |
210 | 210 | try { |
211 | - rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . time() . '-' . basename($destination)); |
|
211 | + rename($destination, dirname($destination).DIRECTORY_SEPARATOR.time().'-'.basename($destination)); |
|
212 | 212 | } catch (\Exception $e) { |
213 | 213 | // |
214 | 214 | } |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | protected function parseCliLog(array $info): string |
225 | 225 | { |
226 | 226 | if ($this->config['json']) { |
227 | - $message = json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
227 | + $message = json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
228 | 228 | } else { |
229 | 229 | $now = $info['timestamp']; |
230 | 230 | unset($info['timestamp']); |
231 | 231 | |
232 | 232 | $message = implode(PHP_EOL, $info); |
233 | 233 | |
234 | - $message = "[{$now}]" . $message . PHP_EOL; |
|
234 | + $message = "[{$now}]".$message.PHP_EOL; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return $message; |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | |
255 | 255 | if ($this->config['json']) { |
256 | 256 | $info = $requestInfo + $info; |
257 | - return json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
257 | + return json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
258 | 258 | } |
259 | 259 | |
260 | - array_unshift($info, "---------------------------------------------------------------" . PHP_EOL . "[{$info['timestamp']}] {$requestInfo['ip']} {$requestInfo['method']} {$requestInfo['host']}{$requestInfo['uri']}"); |
|
260 | + array_unshift($info, "---------------------------------------------------------------".PHP_EOL."[{$info['timestamp']}] {$requestInfo['ip']} {$requestInfo['method']} {$requestInfo['host']}{$requestInfo['uri']}"); |
|
261 | 261 | unset($info['timestamp']); |
262 | 262 | |
263 | - return implode(PHP_EOL, $info) . PHP_EOL; |
|
263 | + return implode(PHP_EOL, $info).PHP_EOL; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | } |