RESAZIP-PC\resaz

update

......@@ -99,26 +99,29 @@ class DaitoExceptionNotifierManager
$arrSummaryWidgets = array(
$this->makeDecoratedTextWidget('time', date('Y-m-d H:i:s')),
$this->makeDecoratedTextWidget('action', $action),
$this->makeDecoratedTextWidget('file', (string) $throwable->getFile()),
$this->makeDecoratedTextWidget('line', (string) $throwable->getLine()),
$this->makeDecoratedTextWidget(
'message',
$this->limitText((string) $throwable->getMessage(), (int) config('daito-exception-notifier.message_max_length', 1000))
$this->makeCompactFileLineWidget((string) $throwable->getFile(), (int) $throwable->getLine()),
array(
'textParagraph' => array(
'text' => '<b>message</b><br/><font color="#d93025">'
. $this->escapeForGoogleChat(
$this->limitText((string) $throwable->getMessage(), (int) config('daito-exception-notifier.message_max_length', 1000))
)
. '</font>',
),
),
);
if ((bool) config('daito-exception-notifier.trace_include_first_app_frame', true)
&& $arrTraceData['first_app_frame'] !== ''
) {
$arrSummaryWidgets[] = $this->makeDecoratedTextWidget('first_app_frame', $arrTraceData['first_app_frame']);
}
// if ((bool) config('daito-exception-notifier.trace_include_first_app_frame', true)
// && $arrTraceData['first_app_frame'] !== ''
// ) {
// $arrSummaryWidgets[] = $this->makeDecoratedTextWidget('first_app_frame', $arrTraceData['first_app_frame']);
// }
return array(
'cardId' => 'daito-exception-alert',
'card' => array(
'header' => array(
'title' => (string) config('daito-exception-notifier.card_title', 'Exception Alert'),
'subtitle' => $action,
'title' => '🚨 ' . (string) config('daito-exception-notifier.card_title', 'Exception Alert'),
),
'sections' => array(
array(
......@@ -307,6 +310,42 @@ class DaitoExceptionNotifierManager
);
}
private function makeCompactFileLineWidget(string $filePath, int $line): array
{
$displayPath = $this->formatCompactPath($filePath);
$lineText = $line > 0 ? (string) $line : '?';
return array(
'textParagraph' => array(
'text' => '<b>location</b> ' . $this->escapeForGoogleChat($displayPath) . ':' . $lineText,
),
);
}
private function formatCompactPath(string $filePath): string
{
if ($filePath === '') {
return '[unknown]';
}
$normalizedPath = str_replace('\\', '/', $filePath);
if (function_exists('base_path')) {
$rootDir = str_replace('\\', '/', base_path());
if ($rootDir !== '' && strpos($normalizedPath, $rootDir . '/') === 0) {
$normalizedPath = substr($normalizedPath, strlen($rootDir) + 1);
}
}
$arrPathParts = explode('/', $normalizedPath);
$pathPartCount = count($arrPathParts);
if ($pathPartCount > 4) {
$arrPathParts = array_slice($arrPathParts, $pathPartCount - 4);
$normalizedPath = '.../' . implode('/', $arrPathParts);
}
return $normalizedPath;
}
private function limitText(string $text, int $maxLength): string
{
$maxLength = max(1, $maxLength);
......