Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
fe74f29b
Unverified
Commit
fe74f29b
authored
Apr 17, 2024
by
Pavel
Committed by
GitHub
Apr 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log render exception via logger interface, check that path (#914)
exists
parent
7a6f62bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
RenderExceptionsHandler.kt
...ain/kotlin/org/jetbrains/skiko/RenderExceptionsHandler.kt
+24
-11
No files found.
skiko/src/awtMain/kotlin/org/jetbrains/skiko/RenderExceptionsHandler.kt
View file @
fe74f29b
...
@@ -10,25 +10,39 @@ internal class RenderExceptionsHandler {
...
@@ -10,25 +10,39 @@ internal class RenderExceptionsHandler {
private
var
output
:
File
?
=
null
private
var
output
:
File
?
=
null
@JvmStatic
@JvmStatic
fun
throwException
(
message
:
String
)
{
fun
throwException
(
message
:
String
)
{
if
(
output
==
null
)
{
output
=
File
(
"${SkikoProperties.dataPath}/skiko-render-exception-${ProcessHandle.current().pid()}.log"
)
}
val
exception
=
RenderException
(
message
)
val
exception
=
RenderException
(
message
)
val
systemInfo
=
systemInfo
()
Logger
.
error
(
exception
)
{
"Render exception\n $systemInfo"
}
if
(
System
.
getProperty
(
"skiko.win.exception.logger.enabled"
)
==
"true"
)
{
if
(
System
.
getProperty
(
"skiko.win.exception.logger.enabled"
)
==
"true"
)
{
writeLog
(
exception
)
try
{
if
(
output
==
null
)
{
output
=
File
(
"${SkikoProperties.dataPath}/skiko-render-exception-${ProcessHandle.current().pid()}.log"
)
output
!!
.
parentFile
.
mkdirs
()
}
output
?.
appendText
(
"$systemInfo\n"
)
output
?.
appendText
(
exceptionToString
(
exception
))
}
catch
(
t
:
Throwable
)
{
Logger
.
error
(
t
)
{
"Failed to write report"
}
}
}
}
throw
exception
throw
exception
}
}
private
fun
writeLog
(
exception
:
Exception
)
{
private
fun
systemInfo
():
String
{
val
outputBuilder
=
StringBuilder
().
apply
{
return
StringBuilder
().
apply
{
append
(
"When: ${SimpleDateFormat("
dd
/
M
/
yyyy
hh
:
mm
:
ss
").format(Date())}\n"
)
append
(
"When: ${SimpleDateFormat("
dd
/
M
/
yyyy
hh
:
mm
:
ss
").format(Date())}\n"
)
append
(
"Skiko version: ${Version.skiko}\n"
)
append
(
"Skiko version: ${Version.skiko}\n"
)
append
(
"OS: $hostFullName\n"
)
append
(
"OS: $hostFullName\n"
)
append
(
"CPU: ${getNativeCpuInfo()}\n"
)
append
(
"CPU: ${getNativeCpuInfo()}\n"
)
append
(
"Graphics adapters:\n${getNativeGraphicsAdapterInfo()}\n"
)
append
(
"Graphics adapters:\n${getNativeGraphicsAdapterInfo()}"
)
}.
toString
()
}
private
fun
exceptionToString
(
exception
:
Exception
):
String
{
return
StringBuilder
().
apply
{
append
(
"Exception message: ${exception.message}\n"
)
append
(
"Exception message: ${exception.message}\n"
)
append
(
"Exception stack trace:\n"
)
append
(
"Exception stack trace:\n"
)
val
stackTrace
=
exception
.
stackTrace
.
filterIndexed
{
line
,
_
->
line
>
1
}
val
stackTrace
=
exception
.
stackTrace
.
filterIndexed
{
line
,
_
->
line
>
1
}
...
@@ -36,8 +50,7 @@ internal class RenderExceptionsHandler {
...
@@ -36,8 +50,7 @@ internal class RenderExceptionsHandler {
append
(
"$line\n"
)
append
(
"$line\n"
)
}
}
append
(
"\n\n"
)
append
(
"\n\n"
)
}
}.
toString
()
output
?.
appendText
(
outputBuilder
.
toString
())
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment