@@ -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) { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file')); |
| 61 | 61 | } |
| 62 | 62 | $this->latest = $this->getConfig('save-path').'/'.$this->getConfig('file-name'); |
| 63 | - \register_shutdown_function([$this,'save']); |
|
| 63 | + \register_shutdown_function([$this, 'save']); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function getDefaultConfig():array |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | protected function packLogFile() |
| 80 | 80 | { |
| 81 | - $logFile= $this->latest; |
|
| 82 | - $path=preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip'); |
|
| 81 | + $logFile = $this->latest; |
|
| 82 | + $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip'); |
|
| 83 | 83 | $zip = new ZipArchive; |
| 84 | 84 | $res = $zip->open($path, ZipArchive::CREATE); |
| 85 | 85 | if ($res === true) { |
| 86 | - if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) { |
|
| 86 | + if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) { |
|
| 87 | 87 | array_push($this->removeFiles, $logFile); |
| 88 | 88 | } |
| 89 | 89 | if (\is_dir($this->getConfig('save-pack-path'))) { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $zip->close(); |
| 98 | 98 | } else { |
| 99 | 99 | if (is_file($logFile) && file_exists($logFile)) { |
| 100 | - rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log'); |
|
| 100 | + rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log'); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | protected function checkSize():bool |
| 111 | 111 | { |
| 112 | - $logFile= $this->latest; |
|
| 112 | + $logFile = $this->latest; |
|
| 113 | 113 | if (file_exists($logFile)) { |
| 114 | 114 | if (filesize($logFile) > $this->getConfig('max-file-size')) { |
| 115 | 115 | return true; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function log($level, string $message, array $context = []) |
| 123 | 123 | { |
| 124 | - if (LogLevel::compare($level, $this->getConfig('log-level')) >=0) { |
|
| 124 | + if (LogLevel::compare($level, $this->getConfig('log-level')) >= 0) { |
|
| 125 | 125 | $replace = []; |
| 126 | 126 | $message = $this->interpolate($message, $context); |
| 127 | 127 | $replace['%level%'] = $level; |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | protected function rollLatest() |
| 135 | 135 | { |
| 136 | 136 | if (isset($this->latest)) { |
| 137 | - $size=ftell($this->temp); |
|
| 137 | + $size = ftell($this->temp); |
|
| 138 | 138 | fseek($this->temp, 0); |
| 139 | 139 | if ($size > 0) { |
| 140 | - $body=fread($this->temp, $size); |
|
| 140 | + $body = fread($this->temp, $size); |
|
| 141 | 141 | file_put_contents($this->latest, $body, FILE_APPEND); |
| 142 | 142 | } |
| 143 | 143 | fclose($this->temp); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $replace = []; |
| 171 | 171 | foreach ($context as $key => $val) { |
| 172 | - $replace['{' . $key . '}'] = $val; |
|
| 172 | + $replace['{'.$key.'}'] = $val; |
|
| 173 | 173 | } |
| 174 | 174 | return strtr($message, $replace); |
| 175 | 175 | } |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -require_once NEBULA_SYSTEM .'/src/component/loader/Path.php'; |
|
| 24 | -require_once NEBULA_SYSTEM .'/src/component/loader/PathTrait.php'; |
|
| 25 | -require_once NEBULA_SYSTEM .'/src/component/loader/PathInterface.php'; |
|
| 26 | -require_once NEBULA_SYSTEM .'/src/component/loader/IncludeManager.php'; |
|
| 27 | -require_once NEBULA_SYSTEM .'/src/component/loader/Loader.php'; |
|
| 28 | -require_once NEBULA_SYSTEM .'/src/application/Loader.php'; |
|
| 23 | +require_once NEBULA_SYSTEM.'/src/component/loader/Path.php'; |
|
| 24 | +require_once NEBULA_SYSTEM.'/src/component/loader/PathTrait.php'; |
|
| 25 | +require_once NEBULA_SYSTEM.'/src/component/loader/PathInterface.php'; |
|
| 26 | +require_once NEBULA_SYSTEM.'/src/component/loader/IncludeManager.php'; |
|
| 27 | +require_once NEBULA_SYSTEM.'/src/component/loader/Loader.php'; |
|
| 28 | +require_once NEBULA_SYSTEM.'/src/application/Loader.php'; |
|