Skip to content

Commit

Permalink
Separate log files according to XDG spec and macOS dir names
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Apr 20, 2024
1 parent 1e54d27 commit fdb37fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class RenderExceptionsHandler {
try {
if (output == null) {
output = File(
"${SkikoProperties.dataPath}/skiko-render-exception-${ProcessHandle.current().pid()}.log"
"${SkikoProperties.logPath}/skiko-render-exception-${ProcessHandle.current().pid()}.log"
)
output!!.parentFile.mkdirs()
}
Expand Down
21 changes: 18 additions & 3 deletions skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ object SkikoProperties {
/**
* The path where to store data files.
*
* It is used for extracting the Skiko binaries (if `libraryPath` isn't null) and logging.
*
* TODO: Use $XDG_STATE_HOME (Unix) / ~/Library/Logs (macOS) for logging instead?
* It is used for extracting the Skiko binaries (if `libraryPath` isn't null).
*/
val dataPath: String get() {
return getProperty("skiko.data.path") ?: when (hostOs) {
Expand All @@ -47,6 +45,23 @@ object SkikoProperties {
}
}

/**
* The path where to store log files.
*/
val logPath: String get() {
return getProperty("skiko.data.path") ?: when (hostOs) {
OS.Windows -> "${getenv("LOCALAPPDATA")}/Skiko"
OS.MacOS, OS.Ios -> "${getProperty("user.home")}/Library/Logs/Skiko"
else -> {
var stateHome = getenv("XDG_STATE_HOME")
if (stateHome == null || !stateHome.startsWith('/')) {
stateHome = "${getProperty("user.home")}/.local/state"
}
return "${stateHome}/skiko"
}
}
}

val vsyncEnabled: Boolean get() = getProperty("skiko.vsync.enabled")?.toBoolean() ?: true

/**
Expand Down

0 comments on commit fdb37fc

Please sign in to comment.