Skip to content

Commit

Permalink
cmd/languageserver: Log path & version at startup (#1326)
Browse files Browse the repository at this point in the history
Fixes #1324

Signed-off-by: Charlie Egan <[email protected]>
  • Loading branch information
charlieegan3 authored Jan 9, 2025
1 parent b909a5c commit d445931
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/languageserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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,
Expand Down

0 comments on commit d445931

Please sign in to comment.