mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
feat(linux): Use XDG_STATE_HOME to storage logs (#1675)
* feat(linux): Use XDG_STATE_HOME to storage logs * fix: Clean LSP suggestions. * fix: Use Platform.environment instead String.fromEnvironment The latter seems return an empty string. See: https://github.com/flutter/flutter/issues/55870#issuecomment-936612420
This commit is contained in:
parent
6a500731d6
commit
e6fee03c20
@ -65,6 +65,11 @@ class AppLogger {
|
||||
if (kIsMacOS) {
|
||||
dir = join((await getLibraryDirectory()).path, "Logs");
|
||||
}
|
||||
|
||||
if (kIsLinux) {
|
||||
dir = join(_getXdgStateHome(), "spotube");
|
||||
}
|
||||
|
||||
final file = File(join(dir, ".spotube_logs"));
|
||||
if (!await file.exists()) {
|
||||
await file.create(recursive: true);
|
||||
@ -88,6 +93,20 @@ class AppLogger {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static String _getXdgStateHome() {
|
||||
// path_provider seems does not support XDG_STATE_HOME,
|
||||
// which is the specification to store application logs on Linux.
|
||||
// See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
// TODO: Use path_provider once it supports XDG_STATE_HOME
|
||||
if (const bool.hasEnvironment("XDG_STATE_HOME")) {
|
||||
String xdgStateHomeRaw = Platform.environment["XDG_STATE_HOME"] ?? "";
|
||||
if (xdgStateHomeRaw.isNotEmpty) {
|
||||
return xdgStateHomeRaw;
|
||||
}
|
||||
}
|
||||
return join(Platform.environment["HOME"] ?? "", ".local", "state");
|
||||
}
|
||||
}
|
||||
|
||||
class AppLoggerProviderObserver extends ProviderObserver {
|
||||
|
Loading…
Reference in New Issue
Block a user