@@ -65,7 +65,7 @@ |
||
| 65 | 65 | public function seek($offset) |
| 66 | 66 | { |
| 67 | 67 | if (!array_key_exists($offset, $this->values)) { |
| 68 | - throw new \OutOfBoundsException("Current cursor is out of range: " . $offset); |
|
| 68 | + throw new \OutOfBoundsException("Current cursor is out of range: ".$offset); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this->values[$offset]; |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | public function seek($offset) |
| 66 | 66 | { |
| 67 | 67 | if (!array_key_exists($offset, $this->values)) { |
| 68 | - throw new \OutOfBoundsException("Current cursor is out of range: " . $offset); |
|
| 68 | + throw new \OutOfBoundsException("Current cursor is out of range: ".$offset); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this->values[$offset]; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | /** |
| 51 | 51 | * {@inheritdoc} |
| 52 | 52 | */ |
| 53 | - public function onMethodInject(IAnnotatable &$instance, Container $container, \ReflectionMethod $method) |
|
| 53 | + public function onMethodInject(IAnnotatable&$instance, Container $container, \ReflectionMethod $method) |
|
| 54 | 54 | { |
| 55 | 55 | $this->injectedLog($this); |
| 56 | 56 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | /** |
| 51 | 51 | * {@inheritdoc} |
| 52 | 52 | */ |
| 53 | - public function onMethodInject(IAnnotatable &$instance, Container $container, \ReflectionMethod $method) |
|
| 53 | + public function onMethodInject(IAnnotatable&$instance, Container $container, \ReflectionMethod $method) |
|
| 54 | 54 | { |
| 55 | 55 | $this->injectedLog($this); |
| 56 | 56 | |
@@ -18,5 +18,5 @@ |
||
| 18 | 18 | * @param Container 依存コンテナ |
| 19 | 19 | * @param ReflectionMethod リフレクションメソッドオブジェクト |
| 20 | 20 | */ |
| 21 | - public function onMethodInject(IAnnotatable &$instance, Container $container, \ReflectionMethod $method); |
|
| 21 | + public function onMethodInject(IAnnotatable&$instance, Container $container, \ReflectionMethod $method); |
|
| 22 | 22 | } |
@@ -183,6 +183,7 @@ |
||
| 183 | 183 | /** |
| 184 | 184 | * ログローテートサイクルを時間に変換 |
| 185 | 185 | * @param string ローテートサイクル |
| 186 | + * @param string $cycle |
|
| 186 | 187 | * @return int ローテート時間 |
| 187 | 188 | */ |
| 188 | 189 | private function cycle2value($cycle) |
@@ -68,11 +68,11 @@ |
||
| 68 | 68 | public function load() |
| 69 | 69 | { |
| 70 | 70 | $this->loadLogLevel() |
| 71 | - ->loadLogFilePath() |
|
| 72 | - ->loadRotateCycle() |
|
| 73 | - ->loadRotateSize() |
|
| 74 | - ->loadApplicationName() |
|
| 75 | - ->loadFormat(); |
|
| 71 | + ->loadLogFilePath() |
|
| 72 | + ->loadRotateCycle() |
|
| 73 | + ->loadRotateSize() |
|
| 74 | + ->loadApplicationName() |
|
| 75 | + ->loadFormat(); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } else { |
| 46 | 46 | $configMap = $this->parseConfig($config); |
| 47 | 47 | if ($configMap === null) { |
| 48 | - throw new LoggerException("Log config file does not exist: " . $config); |
|
| 48 | + throw new LoggerException("Log config file does not exist: ".$config); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | $this->ioContainer = new Container(); |
| 54 | 54 | |
| 55 | 55 | $rootDir = $this->getApplicationRoot(); |
| 56 | - $this->ioContainer->file = function () use ($rootDir, $configMap) { |
|
| 56 | + $this->ioContainer->file = function() use ($rootDir, $configMap) { |
|
| 57 | 57 | if (!array_key_exists("path", $configMap)) { |
| 58 | 58 | throw new LoggerException("Log path must be defined."); |
| 59 | 59 | } |
| 60 | - return new File($rootDir . "/" . $configMap["path"]); |
|
| 60 | + return new File($rootDir."/".$configMap["path"]); |
|
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | $this->configMap = $configMap; |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $file = $this->ioContainer->file; |
| 112 | 112 | if (!($file->exists() && $file->isFile())) { |
| 113 | - throw new LoggerException("Log directory does not exist: " . $file->getFilePath()); |
|
| 113 | + throw new LoggerException("Log directory does not exist: ".$file->getFilePath()); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $this->logContainer->logPath = $file->getFilePath(); |
| 117 | - $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function ($matches) { |
|
| 117 | + $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function($matches) { |
|
| 118 | 118 | return "$matches[1].status"; |
| 119 | 119 | }, $this->logContainer->logPath); |
| 120 | 120 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $rotateSize = intval($this->configMap["rotate_size"]); |
| 145 | 145 | // ローテートサイズが不正の場合(正の整数以外の値が設定された場合) |
| 146 | 146 | if ($rotateSize <= 0) { |
| 147 | - throw new LoggerException("Invalid log rotate size: " . $this->configMap["rotate_size"]); |
|
| 147 | + throw new LoggerException("Invalid log rotate size: ".$this->configMap["rotate_size"]); |
|
| 148 | 148 | } |
| 149 | 149 | $this->logContainer->rotateSize = $rotateSize; |
| 150 | 150 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | case 'year': |
| 207 | 207 | return $year_to_h; |
| 208 | 208 | default: |
| 209 | - throw new LoggerException("Invalid log rotate cycle: " . $cycle); |
|
| 209 | + throw new LoggerException("Invalid log rotate cycle: ".$cycle); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * フォーマット済みメッセージを返却する |
| 36 | 36 | * @param string メッセージ |
| 37 | 37 | * @param string ログレベル |
| 38 | - * @return フォーマット済みメッセージ |
|
| 38 | + * @return string |
|
| 39 | 39 | */ |
| 40 | 40 | public function getFormattedMessage($message, $logLevel) |
| 41 | 41 | { |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | // メッセージ |
| 50 | 50 | $formattedMessage = preg_replace('/%m/', $message, $formattedMessage); |
| 51 | 51 | |
| 52 | - return $formattedMessage . PHP_EOL; |
|
| 52 | + return $formattedMessage.PHP_EOL; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $sapi = php_sapi_name(); |
| 34 | 34 | if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'http') { |
| 35 | - echo $text . "<br>"; |
|
| 35 | + echo $text."<br>"; |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * インスタンスを返却する |
| 88 | - * @return WebStream\Module\Logger ロガーインスタンス |
|
| 88 | + * @return Logger ロガーインスタンス |
|
| 89 | 89 | */ |
| 90 | 90 | public static function getInstance() |
| 91 | 91 | { |
@@ -171,6 +171,8 @@ discard block |
||
| 171 | 171 | * @param string ログレベル文字列 |
| 172 | 172 | * @param string 出力文字列 |
| 173 | 173 | * @param array<mixed> 埋め込み値リスト |
| 174 | + * @param integer $level |
|
| 175 | + * @param string $msg |
|
| 174 | 176 | */ |
| 175 | 177 | public function write($level, $msg, $context = null) |
| 176 | 178 | { |
@@ -267,6 +269,8 @@ discard block |
||
| 267 | 269 | * ローテートを実行する |
| 268 | 270 | * @param integer 作成日時のUnixTime |
| 269 | 271 | * @param integer 現在日時のUnixTime |
| 272 | + * @param integer $from |
|
| 273 | + * @param integer $to |
|
| 270 | 274 | */ |
| 271 | 275 | private function runRotate($from, $to) |
| 272 | 276 | { |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $this->ioContainer = new Container(); |
| 77 | 77 | |
| 78 | - $this->ioContainer->statusReader = function () use ($statusFile) { |
|
| 78 | + $this->ioContainer->statusReader = function() use ($statusFile) { |
|
| 79 | 79 | return new FileReader($statusFile); |
| 80 | 80 | }; |
| 81 | - $this->ioContainer->statusWriter = function () use ($statusFile) { |
|
| 81 | + $this->ioContainer->statusWriter = function() use ($statusFile) { |
|
| 82 | 82 | return new SimpleFileWriter($statusFile->getFilePath()); |
| 83 | 83 | }; |
| 84 | - $this->ioContainer->logWriter = function () use ($logFile) { |
|
| 84 | + $this->ioContainer->logWriter = function() use ($logFile) { |
|
| 85 | 85 | return new SimpleFileWriter($logFile->getFilePath()); |
| 86 | 86 | }; |
| 87 | 87 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | date_default_timezone_set('Asia/Tokyo'); |
| 203 | 203 | $msec = sprintf("%2d", floatval(microtime()) * 100); |
| 204 | 204 | |
| 205 | - return strftime("%Y-%m-%d %H:%M:%S") . "," . $msec; |
|
| 205 | + return strftime("%Y-%m-%d %H:%M:%S").",".$msec; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $outputter->write(self::$formatter->getFormattedMessage($msg, $level)); |
| 241 | 241 | } |
| 242 | 242 | } else { |
| 243 | - $this->ioContainer->logWriter->write(self::$formatter->getFormattedMessage($msg, $level) . PHP_EOL); |
|
| 243 | + $this->ioContainer->logWriter->write(self::$formatter->getFormattedMessage($msg, $level).PHP_EOL); |
|
| 244 | 244 | } |
| 245 | 245 | } catch (LoggerException $e) { |
| 246 | 246 | throw $e; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | { |
| 288 | 288 | $content = $this->ioContainer->statusReader->read(); |
| 289 | 289 | if (!preg_match('/^\d{10}$/', $content)) { |
| 290 | - throw new LoggerException("Invalid log state file contents: " . $content); |
|
| 290 | + throw new LoggerException("Invalid log state file contents: ".$content); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return intval($content); |