From d445931f5c71d8e97b466c60a50f78798fe478f0 Mon Sep 17 00:00:00 2001 From: Charlie Egan Date: Thu, 9 Jan 2025 14:23:18 +0000 Subject: [PATCH] cmd/languageserver: Log path & version at startup (#1326) Fixes https://github.com/StyraInc/regal/issues/1324 Signed-off-by: Charlie Egan --- cmd/languageserver.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/languageserver.go b/cmd/languageserver.go index 5f180b62..3acd0f90 100644 --- a/cmd/languageserver.go +++ b/cmd/languageserver.go @@ -5,12 +5,14 @@ import ( "fmt" "os" "os/signal" + "path/filepath" "syscall" "github.com/spf13/cobra" "github.com/styrainc/regal/internal/lsp" "github.com/styrainc/regal/internal/lsp/log" + "github.com/styrainc/regal/pkg/version" ) func init() { @@ -25,6 +27,23 @@ func init() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + exe, err := os.Executable() + if err != nil { + fmt.Fprintln(os.Stderr, "error getting executable:", err) + } else { + absPath, err := filepath.Abs(exe) + if err != nil { + fmt.Fprintln(os.Stderr, "error getting executable path:", err) + } else { + v := version.Version + if v == "" { + v = "Unknown" + } + + fmt.Fprintf(os.Stderr, "Regal Language Server (path: %s, version: %s)", absPath, v) + } + } + opts := &lsp.LanguageServerOptions{ LogWriter: os.Stderr, LogLevel: log.LevelMessage,