summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hexai-lsp/main.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/cmd/hexai-lsp/main.go b/cmd/hexai-lsp/main.go
index 3704cbf..828d0f8 100644
--- a/cmd/hexai-lsp/main.go
+++ b/cmd/hexai-lsp/main.go
@@ -14,7 +14,8 @@ import (
)
func main() {
- logPath := flag.String("log", "/tmp/hexai-lsp.log", "path to log file (optional)")
+ defaultLog := defaultLogPath()
+ logPath := flag.String("log", defaultLog, "path to log file (optional)")
defaultCfg := defaultConfigPath()
configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultCfg))
showVersion := flag.Bool("version", false, "print version and exit")
@@ -37,3 +38,15 @@ func defaultConfigPath() string {
}
return path
}
+
+// defaultLogPath returns the default LSP log file path in the state directory.
+// Falls back to /tmp if state directory cannot be determined.
+// defaultLogPath returns the default LSP log file path in the state directory.
+// Panics if state directory cannot be created.
+func defaultLogPath() string {
+ stateDir, err := appconfig.StateDir()
+ if err != nil {
+ panic(fmt.Sprintf("cannot create state directory: %v", err))
+ }
+ return fmt.Sprintf("%s/hexai-lsp.log", stateDir)
+}