@@ -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; |
| 14 | 14 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function getConfig($name = null, $default = null) |
| 57 | 57 | { |
| 58 | 58 | if (!is_null($name)) { |
| 59 | - return $this->app->config->get('log.' . $name, $default); |
|
| 59 | + return $this->app->config->get('log.'.$name, $default); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $this->app->config->get('log'); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function record($msg, string $type = 'info', array $context = [], $lazy = true) |
| 182 | 182 | { |
| 183 | - $channel = $this->getConfig('type_channel.' . $type); |
|
| 183 | + $channel = $this->getConfig('type_channel.'.$type); |
|
| 184 | 184 | |
| 185 | 185 | $this->channel($channel)->record($msg, $type, $context, $lazy); |
| 186 | 186 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | // +---------------------------------------------------------------------- |
| 9 | 9 | // | Author: yunwuxin <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think; |
| 14 | 14 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | protected function resolveClass($type) |
| 94 | 94 | { |
| 95 | 95 | if ($this->namespace || false !== strpos($type, '\\')) { |
| 96 | - $class = false !== strpos($type, '\\') ? $type : $this->namespace . Str::studly($type); |
|
| 96 | + $class = false !== strpos($type, '\\') ? $type : $this->namespace.Str::studly($type); |
|
| 97 | 97 | |
| 98 | 98 | if (class_exists($class)) { |
| 99 | 99 | return $class; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $type = $this->resolveType($name); |
| 116 | 116 | $config = $this->resolveConfig($name); |
| 117 | 117 | |
| 118 | - $method = 'create' . Str::studly($type) . 'Driver'; |
|
| 118 | + $method = 'create'.Str::studly($type).'Driver'; |
|
| 119 | 119 | |
| 120 | 120 | if (method_exists($this, $method)) { |
| 121 | 121 | return $this->$method($config); |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | if (is_string($msg) && !empty($context)) { |
| 121 | 121 | $replace = []; |
| 122 | 122 | foreach ($context as $key => $val) { |
| 123 | - $replace['{' . $key . '}'] = $val; |
|
| 123 | + $replace['{'.$key.'}'] = $val; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $msg = strtr($msg, $replace); |
@@ -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 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if (empty($this->config['path'])) { |
| 51 | - $this->config['path'] = $app->getRuntimePath() . 'log'; |
|
| 51 | + $this->config['path'] = $app->getRuntimePath().'log'; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -78,8 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $message[] = $this->config['json'] ? |
| 81 | - json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : |
|
| 82 | - sprintf($this->config['format'], $time, $type, $msg); |
|
| 81 | + json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : sprintf($this->config['format'], $time, $type, $msg); |
|
| 83 | 82 | } |
| 84 | 83 | |
| 85 | 84 | if (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level'])) { |
@@ -117,7 +116,7 @@ discard block |
||
| 117 | 116 | $info[$type] = is_array($msg) ? implode(PHP_EOL, $msg) : $msg; |
| 118 | 117 | } |
| 119 | 118 | |
| 120 | - $message = implode(PHP_EOL, $info) . PHP_EOL; |
|
| 119 | + $message = implode(PHP_EOL, $info).PHP_EOL; |
|
| 121 | 120 | |
| 122 | 121 | return error_log($message, 3, $destination); |
| 123 | 122 | } |
@@ -134,7 +133,7 @@ discard block |
||
| 134 | 133 | } |
| 135 | 134 | |
| 136 | 135 | if ($this->config['max_files']) { |
| 137 | - $files = glob($this->config['path'] . '*.log'); |
|
| 136 | + $files = glob($this->config['path'].'*.log'); |
|
| 138 | 137 | |
| 139 | 138 | try { |
| 140 | 139 | if (count($files) > $this->config['max_files']) { |
@@ -147,16 +146,16 @@ discard block |
||
| 147 | 146 | |
| 148 | 147 | if ($this->config['single']) { |
| 149 | 148 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
| 150 | - $destination = $this->config['path'] . $name . '.log'; |
|
| 149 | + $destination = $this->config['path'].$name.'.log'; |
|
| 151 | 150 | } else { |
| 152 | 151 | |
| 153 | 152 | if ($this->config['max_files']) { |
| 154 | - $filename = date('Ymd') . '.log'; |
|
| 153 | + $filename = date('Ymd').'.log'; |
|
| 155 | 154 | } else { |
| 156 | - $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . '.log'; |
|
| 155 | + $filename = date('Ym').DIRECTORY_SEPARATOR.date('d').'.log'; |
|
| 157 | 156 | } |
| 158 | 157 | |
| 159 | - $destination = $this->config['path'] . $filename; |
|
| 158 | + $destination = $this->config['path'].$filename; |
|
| 160 | 159 | } |
| 161 | 160 | |
| 162 | 161 | return $destination; |
@@ -175,14 +174,14 @@ discard block |
||
| 175 | 174 | if ($this->config['single']) { |
| 176 | 175 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
| 177 | 176 | |
| 178 | - $name .= '_' . $type; |
|
| 177 | + $name .= '_'.$type; |
|
| 179 | 178 | } elseif ($this->config['max_files']) { |
| 180 | - $name = date('Ymd') . '_' . $type; |
|
| 179 | + $name = date('Ymd').'_'.$type; |
|
| 181 | 180 | } else { |
| 182 | - $name = date('d') . '_' . $type; |
|
| 181 | + $name = date('d').'_'.$type; |
|
| 183 | 182 | } |
| 184 | 183 | |
| 185 | - return $path . DIRECTORY_SEPARATOR . $name . '.log'; |
|
| 184 | + return $path.DIRECTORY_SEPARATOR.$name.'.log'; |
|
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | /** |
@@ -195,7 +194,7 @@ discard block |
||
| 195 | 194 | { |
| 196 | 195 | if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { |
| 197 | 196 | try { |
| 198 | - rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . time() . '-' . basename($destination)); |
|
| 197 | + rename($destination, dirname($destination).DIRECTORY_SEPARATOR.time().'-'.basename($destination)); |
|
| 199 | 198 | } catch (\Exception $e) { |
| 200 | 199 | // |
| 201 | 200 | } |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | if ($this->config['debug']) { |
| 74 | 74 | |
| 75 | 75 | if (isset($_SERVER['HTTP_HOST'])) { |
| 76 | - $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 76 | + $current_uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
| 77 | 77 | } else { |
| 78 | - $current_uri = 'cmd:' . implode(' ', $_SERVER['argv']); |
|
| 78 | + $current_uri = 'cmd:'.implode(' ', $_SERVER['argv']); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // 基本信息 |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | foreach ($log as $type => $val) { |
| 90 | 90 | $trace[] = [ |
| 91 | 91 | 'type' => 'groupCollapsed', |
| 92 | - 'msg' => '[ ' . $type . ' ]', |
|
| 92 | + 'msg' => '[ '.$type.' ]', |
|
| 93 | 93 | 'css' => isset($this->css[$type]) ? $this->css[$type] : '', |
| 94 | 94 | ]; |
| 95 | 95 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ]; |
| 176 | 176 | |
| 177 | 177 | $msg = @json_encode($logs); |
| 178 | - $address = '/' . $client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 |
|
| 178 | + $address = '/'.$client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 |
|
| 179 | 179 | |
| 180 | 180 | $this->send($this->config['host'], $msg, $address); |
| 181 | 181 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | protected function send($host, $message = '', $address = '/') |
| 250 | 250 | { |
| 251 | - $url = 'http://' . $host . ':' . $this->port . $address; |
|
| 251 | + $url = 'http://'.$host.':'.$this->port.$address; |
|
| 252 | 252 | $ch = curl_init(); |
| 253 | 253 | |
| 254 | 254 | curl_setopt($ch, CURLOPT_URL, $url); |