|
@@ -129,6 +129,7 @@ class TshieldWebhookController
|
|
|
'method' => $method,
|
|
'method' => $method,
|
|
|
'uri' => $uri,
|
|
'uri' => $uri,
|
|
|
'ip' => $ip,
|
|
'ip' => $ip,
|
|
|
|
|
+ 'log_file' => $this->logFilePath,
|
|
|
'request_raw' => $rawBody,
|
|
'request_raw' => $rawBody,
|
|
|
'request_json' => $decodedBody,
|
|
'request_json' => $decodedBody,
|
|
|
'response_status' => $response->getStatusCode(),
|
|
'response_status' => $response->getStatusCode(),
|
|
@@ -144,9 +145,16 @@ class TshieldWebhookController
|
|
|
$encoded = '{"ts":"' . $ts . '","service":"tshield_webhook","request_id":"' . $requestId . '","error":"unable_to_encode_log"}';
|
|
$encoded = '{"ts":"' . $ts . '","service":"tshield_webhook","request_id":"' . $requestId . '","error":"unable_to_encode_log"}';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $written = false;
|
|
|
try {
|
|
try {
|
|
|
- @file_put_contents($this->logFilePath, $encoded . "\n", FILE_APPEND | LOCK_EX);
|
|
|
|
|
|
|
+ $written = (@file_put_contents($this->logFilePath, $encoded . "\n", FILE_APPEND | LOCK_EX) !== false);
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
|
|
+ $written = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!$written) {
|
|
|
|
|
+ $lastError = error_get_last();
|
|
|
|
|
+ error_log('[TShieldWebhook] failed_to_write_log file=' . $this->logFilePath . ' error=' . json_encode($lastError));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
error_log('[TShieldWebhook] ' . $encoded);
|
|
error_log('[TShieldWebhook] ' . $encoded);
|
|
@@ -168,6 +176,7 @@ class TshieldWebhookController
|
|
|
'method' => $method,
|
|
'method' => $method,
|
|
|
'uri' => $uri,
|
|
'uri' => $uri,
|
|
|
'ip' => $ip,
|
|
'ip' => $ip,
|
|
|
|
|
+ 'log_file' => $this->logFilePath,
|
|
|
'request_raw' => $rawBody,
|
|
'request_raw' => $rawBody,
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -176,9 +185,16 @@ class TshieldWebhookController
|
|
|
$encoded = '{"ts":"' . $ts . '","service":"tshield_webhook","event":"received","request_id":"' . $requestId . '","error":"unable_to_encode_log"}';
|
|
$encoded = '{"ts":"' . $ts . '","service":"tshield_webhook","event":"received","request_id":"' . $requestId . '","error":"unable_to_encode_log"}';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $written = false;
|
|
|
try {
|
|
try {
|
|
|
- @file_put_contents($this->logFilePath, $encoded . "\n", FILE_APPEND | LOCK_EX);
|
|
|
|
|
|
|
+ $written = (@file_put_contents($this->logFilePath, $encoded . "\n", FILE_APPEND | LOCK_EX) !== false);
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
|
|
+ $written = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!$written) {
|
|
|
|
|
+ $lastError = error_get_last();
|
|
|
|
|
+ error_log('[TShieldWebhook] failed_to_write_log file=' . $this->logFilePath . ' error=' . json_encode($lastError));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
error_log('[TShieldWebhook] ' . $encoded);
|
|
error_log('[TShieldWebhook] ' . $encoded);
|