Skip to content

Commit 8cba105

Browse files
authored
Update Middleware.php
1 parent c1b2e19 commit 8cba105

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Middleware.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(Request $request, callable $next): Response
5555
if (!$initialized_think_orm) {
5656
try {
5757
ThinkDb::setLog(function ($type, $log) {
58-
Context::get()->webmanLogs .= "[SQL]\t" . trim($log) . PHP_EOL;
58+
Context::get()->webmanLogs = (Context::get()->webmanLogs ?? '') . "[SQL]\t" . trim($log) . PHP_EOL;
5959
});
6060
} catch (Throwable $e) {}
6161
$initialized_think_orm = true;
@@ -68,7 +68,7 @@ public function process(Request $request, callable $next): Response
6868
if ($request->method() === 'POST') {
6969
$logs .= "[POST]\t" . var_export($request->post(), true) . PHP_EOL;
7070
}
71-
$logs .= Context::get()->webmanLogs;
71+
$logs = $logs . (Context::get()->webmanLogs ?? '');
7272

7373
// think-orm如果被使用,则记录think-orm的日志
7474
if ($loaded_think_db = (class_exists(ThinkDb::class, false) && class_exists(Mysql::class, false))) {
@@ -165,7 +165,7 @@ protected function initDbListen()
165165
try {
166166
$log = vsprintf($sql, $query->bindings);
167167
} catch (\Throwable $e) {}
168-
Context::get()->webmanLogs .= "[SQL]\t[connection:{$query->connectionName}] $log [{$query->time} ms]" . PHP_EOL;
168+
Context::get()->webmanLogs = (Context::get()->webmanLogs ?? '') . "[SQL]\t[connection:{$query->connectionName}] $log [{$query->time} ms]" . PHP_EOL;
169169
});
170170
$capsule->setEventDispatcher($dispatcher);
171171
} catch (\Throwable $e) {
@@ -198,7 +198,7 @@ protected function tryInitRedisListen(): array
198198
$item = implode('\', \'', $item);
199199
}
200200
}
201-
Context::get()->webmanLogs .= "[Redis]\t[connection:{$command->connectionName}] Redis::{$command->command}('" . implode('\', \'', $command->parameters) . "') ({$command->time} ms)" . PHP_EOL;
201+
Context::get()->webmanLogs = (Context::get()->webmanLogs ?? '') . "[Redis]\t[connection:{$command->connectionName}] Redis::{$command->command}('" . implode('\', \'', $command->parameters) . "') ({$command->time} ms)" . PHP_EOL;
202202
});
203203
$listened_names[$name] = $name;
204204
$new_names[] = $name;

0 commit comments

Comments
 (0)