@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @throws FileLoggerException |
47 | 47 | * @param array $config |
48 | 48 | */ |
49 | - public function __construct(array $config=[]) |
|
49 | + public function __construct(array $config = []) |
|
50 | 50 | { |
51 | 51 | $this->applyConfig($config); |
52 | 52 | $temp = tmpfile(); |
53 | 53 | if ($temp === false) { |
54 | - $this->tempname = $this->getConfig('save-path').'/log-'. microtime(true).'.tmp'; |
|
54 | + $this->tempname = $this->getConfig('save-path').'/log-'.microtime(true).'.tmp'; |
|
55 | 55 | $temp = fopen($this->tempname, 'w+'); |
56 | 56 | } |
57 | 57 | if ($temp !== false) { |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function packLogFile() |
79 | 79 | { |
80 | - $logFile= $this->latest; |
|
81 | - $path=preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip'); |
|
80 | + $logFile = $this->latest; |
|
81 | + $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip'); |
|
82 | 82 | $zip = new ZipArchive; |
83 | 83 | $res = $zip->open($path, ZipArchive::CREATE); |
84 | 84 | if ($res === true) { |
85 | - if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) { |
|
85 | + if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) { |
|
86 | 86 | array_push($this->removeFiles, $logFile); |
87 | 87 | } |
88 | 88 | if (\is_dir($this->getConfig('save-pack-path'))) { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $zip->close(); |
97 | 97 | } else { |
98 | 98 | if (is_file($logFile) && file_exists($logFile)) { |
99 | - rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log'); |
|
99 | + rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function checkSize():bool |
110 | 110 | { |
111 | - $logFile= $this->latest; |
|
111 | + $logFile = $this->latest; |
|
112 | 112 | if (file_exists($logFile)) { |
113 | 113 | if (filesize($logFile) > $this->getConfig('max-file-size')) { |
114 | 114 | return true; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | public function log($level, string $message, array $context = []) |
122 | 122 | { |
123 | - if (LogLevel::compare($level, $this->getConfig('log-level')) >=0) { |
|
123 | + if (LogLevel::compare($level, $this->getConfig('log-level')) >= 0) { |
|
124 | 124 | $replace = []; |
125 | 125 | $message = $this->interpolate($message, $context); |
126 | 126 | $replace['%level%'] = $level; |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | protected function rollLatest() |
134 | 134 | { |
135 | 135 | if (isset($this->latest)) { |
136 | - $size=ftell($this->temp); |
|
136 | + $size = ftell($this->temp); |
|
137 | 137 | fseek($this->temp, 0); |
138 | 138 | if ($size > 0) { |
139 | - $body=fread($this->temp, $size); |
|
139 | + $body = fread($this->temp, $size); |
|
140 | 140 | file_put_contents($this->latest, $body, FILE_APPEND); |
141 | 141 | } |
142 | 142 | fclose($this->temp); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | { |
169 | 169 | $replace = []; |
170 | 170 | foreach ($context as $key => $val) { |
171 | - $replace['{' . $key . '}'] = $val; |
|
171 | + $replace['{'.$key.'}'] = $val; |
|
172 | 172 | } |
173 | 173 | return strtr($message, $replace); |
174 | 174 | } |