Skip to content

Commit

Permalink
Fix logging in LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Apr 4, 2024
1 parent caf69d8 commit adb641e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/cmd/lsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import (
"context"
"time"

"github.com/go-logr/zerologr"
"github.com/jzelinskie/cobrautil/v2"
"github.com/jzelinskie/cobrautil/v2/cobrazerolog"
"github.com/rs/zerolog"
"github.com/spf13/cobra"

"github.com/authzed/spicedb/internal/logging"
"github.com/authzed/spicedb/internal/lsp"
"github.com/authzed/spicedb/pkg/cmd/termination"
"github.com/authzed/spicedb/pkg/releases"
)

// LSPConfig is the configuration for the LSP command.
Expand All @@ -33,6 +39,15 @@ func NewLSPCommand(programName string, config *LSPConfig) *cobra.Command {
return &cobra.Command{
Use: "lsp",
Short: "serve language server protocol",
PreRunE: cobrautil.CommandStack(
cobrautil.SyncViperDotEnvPreRunE(programName, "spicedb.env", zerologr.New(&logging.Logger)),
cobrazerolog.New(
cobrazerolog.WithTarget(func(logger zerolog.Logger) {
logging.SetGlobalLogger(logger)
}),
).RunE(),
releases.CheckAndLogRunE(),
),
RunE: termination.PublishError(func(cmd *cobra.Command, args []string) error {
srv, err := config.Complete(cmd.Context())
if err != nil {
Expand Down

0 comments on commit adb641e

Please sign in to comment.