Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Satini_pvduc
/
daito-utils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
RESAZIP-PC\resaz
2026-02-23 23:46:20 +0700
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
a1bfc0bba4c785b61da94c099fc822c2f37f3c38
a1bfc0bb
1 parent
9fe3ba35
update
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
12 deletions
src/DaitoExceptionNotifier/DaitoExceptionNotifierManager.php
src/DaitoExceptionNotifier/DaitoExceptionNotifierManager.php
View file @
a1bfc0b
...
...
@@ -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
);
...
...
Please
register
or
sign in
to post a comment