@@ -7,12 +7,12 @@ |
||
7 | 7 | use suda\application\builder\ApplicationBuilder; |
8 | 8 | use suda\framework\http\HTTPResponse as Response; |
9 | 9 | |
10 | -require_once __DIR__ .'/loader.php'; |
|
10 | +require_once __DIR__.'/loader.php'; |
|
11 | 11 | |
12 | 12 | // 初始化系统加载器 |
13 | 13 | $loader = new Loader; |
14 | 14 | $loader->register(); |
15 | -$loader->addIncludePath(SUDA_SYSTEM .'/src', 'suda'); |
|
15 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
16 | 16 | // 初始化数据目录 |
17 | 17 | defined('SUDA_DATA') or define('SUDA_DATA', Path::toAbsolutePath('~/data')); |
18 | 18 | defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
@@ -2,13 +2,13 @@ |
||
2 | 2 | $host = $argv[1] ?? '127.0.0.1:9501'; |
3 | 3 | list($ip, $port) = explode(':', $host); |
4 | 4 | |
5 | -define('SUDA_APP', __DIR__ . '/app'); |
|
6 | -define('SUDA_DATA', __DIR__ . '/data'); |
|
7 | -define('SUDA_SYSTEM', __DIR__ . '/suda'); |
|
5 | +define('SUDA_APP', __DIR__.'/app'); |
|
6 | +define('SUDA_DATA', __DIR__.'/data'); |
|
7 | +define('SUDA_SYSTEM', __DIR__.'/suda'); |
|
8 | 8 | define('SUDA_PUBLIC', __DIR__); |
9 | 9 | define('SUDA_DEBUG', true); |
10 | 10 | define('SUDA_DEBUG_LEVEL', 'info'); |
11 | -define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
11 | +define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
12 | 12 | |
13 | 13 | // 设置IP或者端口 |
14 | 14 | define('SUDA_SWOOLE_IP', $ip); |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | { |
92 | 92 | $msec = explode('.', microtime(true))[1]; |
93 | 93 | $save = $this->getConfig('save-path'); |
94 | - $this->tempName = $save . '/' . date('YmdHis') . '.' . $msec . '.log'; |
|
94 | + $this->tempName = $save.'/'.date('YmdHis').'.'.$msec.'.log'; |
|
95 | 95 | $temp = fopen($this->tempName, 'w+'); |
96 | 96 | if ($temp !== false) { |
97 | 97 | $this->temp = $temp; |
98 | 98 | } else { |
99 | - throw new FileLoggerException(__METHOD__ . ':' . sprintf('cannot create log file')); |
|
99 | + throw new FileLoggerException(__METHOD__.':'.sprintf('cannot create log file')); |
|
100 | 100 | } |
101 | - $this->latest = $save . '/' . $this->getConfig('file-name'); |
|
101 | + $this->latest = $save.'/'.$this->getConfig('file-name'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | $path = preg_replace( |
127 | 127 | '/[\\\\]+/', |
128 | 128 | '/', |
129 | - $this->getConfig('save-zip-path') . '/' . date('Y-m-d') . '.zip' |
|
129 | + $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip' |
|
130 | 130 | ); |
131 | 131 | $zip = $this->getZipArchive($path); |
132 | 132 | if ($zip !== null) { |
133 | - if ($zip->addFile($logFile, date('Y-m-d') . '-' . $zip->numFiles . '.log')) { |
|
133 | + if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) { |
|
134 | 134 | array_push($this->removeFiles, $logFile); |
135 | 135 | } |
136 | 136 | if (is_dir($this->getConfig('save-dump-path'))) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | RecursiveDirectoryIterator::SKIP_DOTS |
140 | 140 | )); |
141 | 141 | foreach ($it as $dumpLog) { |
142 | - if ($zip->addFile($dumpLog, 'dump/' . basename($dumpLog))) { |
|
142 | + if ($zip->addFile($dumpLog, 'dump/'.basename($dumpLog))) { |
|
143 | 143 | array_push($this->removeFiles, $dumpLog); |
144 | 144 | } |
145 | 145 | } |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | rename( |
151 | 151 | $logFile, |
152 | 152 | $this->getConfig('save-path') |
153 | - . '/' . date('Y-m-d') |
|
154 | - . '-' . substr(md5_file($logFile), 0, 8) . '.log' |
|
153 | + . '/'.date('Y-m-d') |
|
154 | + . '-'.substr(md5_file($logFile), 0, 8).'.log' |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $replace['%level%'] = $level; |
208 | 208 | $replace['%message%'] = $message; |
209 | 209 | $write = strtr($this->getConfig('log-format'), $replace); |
210 | - fwrite($this->getAvailableWrite(), $write . PHP_EOL); |
|
210 | + fwrite($this->getAvailableWrite(), $write.PHP_EOL); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } elseif (null === $val) { |
284 | 284 | $val = 'null'; |
285 | 285 | } |
286 | - $replace['{' . $key . '}'] = $val; |
|
286 | + $replace['{'.$key.'}'] = $val; |
|
287 | 287 | } |
288 | 288 | return strtr($message, $replace); |
289 | 289 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once __DIR__ . '/loader.php'; |
|
2 | +require_once __DIR__.'/loader.php'; |
|
3 | 3 | |
4 | 4 | use Swoole\Http\Server; |
5 | 5 | use suda\swoole\Request; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | // 初始化系统加载器 |
17 | 17 | $loader = new Loader; |
18 | 18 | $loader->register(); |
19 | -$loader->addIncludePath(SUDA_SYSTEM . '/src', 'suda'); |
|
19 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
20 | 20 | |
21 | 21 | // 创建应用 |
22 | 22 | $application = ApplicationBuilder::build($loader, SUDA_APP, SUDA_APP_MANIFEST, SUDA_DATA); |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | $application->config()->set('copy-static-source', false); |
29 | 29 | $http = new Server(SUDA_SWOOLE_IP, SUDA_SWOOLE_PORT); |
30 | 30 | |
31 | -$http->on('request', function ($request, $response) use ($application) { |
|
31 | +$http->on('request', function($request, $response) use ($application) { |
|
32 | 32 | // 拷贝副本 |
33 | 33 | $runApplication = clone $application; |
34 | 34 | // 文件日志记录 |
35 | 35 | $logger = new FileLogger( |
36 | 36 | [ |
37 | 37 | 'log-level' => SUDA_DEBUG_LEVEL, |
38 | - 'save-path' => $application->getDataPath() . '/logs', |
|
39 | - 'save-zip-path' => $application->getDataPath() . '/logs/zip', |
|
40 | - 'save-dump-path' => $application->getDataPath() . '/logs/dump', |
|
38 | + 'save-path' => $application->getDataPath().'/logs', |
|
39 | + 'save-zip-path' => $application->getDataPath().'/logs/zip', |
|
40 | + 'save-dump-path' => $application->getDataPath().'/logs/dump', |
|
41 | 41 | 'log-format' => '%message%', |
42 | 42 | ] |
43 | 43 | ); |