Skip to content

Commit 9d6e003

Browse files
committed
* 修复请求链log_id的问题
1 parent d6f35dc commit 9d6e003

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/Base/Output.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ public function outputView(array $data, $view = null)
309309
*/
310310
public function end($output = '', $gzip = true)
311311
{
312+
$this->setHeader('X-Ngx-LogId', $this->getContext()->getLogId());
312313
$acceptEncoding = strtolower($this->request->header['accept-encoding'] ?? '');
313314
if ($gzip && strpos($acceptEncoding, 'gzip') !== false) {
314315
$this->response->gzip(1);

src/HttpServer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function genLogId($request)
266266
static $i = 0;
267267
$i || $i = mt_rand(1, 0x7FFFFF);
268268

269-
$logId = $request->header['log_id'] ?? '' ;
269+
$logId = $request->header['x-ngx-logid'] ?? $request->header['log_id'] ?? '' ;
270270

271271
if (!$logId) {
272272
$logId = sprintf("%08x%06x%04x%06x",

0 commit comments

Comments
 (0)