Skip to content

Commit 0423600

Browse files
committed
improve log
1 parent 79bc633 commit 0423600

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Helper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ function generateLog($var, $logFileName, $logType = 'error'): void
3636
$attempts = $var['attempt'] ?? 0;
3737
$errorInfo = $var['errorInfo'][2] ?? '';
3838

39-
if ($logType === 'error') {
40-
$log->error($attempts . ' ' . $errorInfo, $payload);
41-
} elseif ($logType === 'warning') {
42-
$log->warning($attempts . ' ' . $errorInfo, $payload);
39+
if ($logType === 'warning') {
40+
// Transaction succeeded after retries
41+
$title = "[MYSQL DEADLOCK RETRY - SUCCESS] Attempts: $attempts - Warning: $errorInfo";
42+
$log->warning($title, $payload);
4343
} else {
44-
$log->info($attempts . ' ' . $errorInfo, $payload);
44+
// Transaction failed after all attempts
45+
$title = "[MYSQL DEADLOCK RETRY - FAILED] Attempts: $attempts - Error: $errorInfo";
46+
$log->error($title, $payload);
4547
}
4648
}
4749
}

0 commit comments

Comments
 (0)