diff --git a/langserver/handle_workspace_did_change_configuration.go b/langserver/handle_workspace_did_change_configuration.go index 163ad48..edaec8d 100644 --- a/langserver/handle_workspace_did_change_configuration.go +++ b/langserver/handle_workspace_did_change_configuration.go @@ -3,6 +3,8 @@ package langserver import ( "context" "encoding/json" + "log" + "os" "time" "github.com/sourcegraph/jsonrpc2" @@ -44,5 +46,21 @@ func (h *langHandler) didChangeConfiguration(config *Config) (any, error) { h.formatDebounce = time.Duration(config.FormatDebounce) } + if config.LogFile != "" { + f, err := os.OpenFile(config.LogFile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o660) + if err == nil { + if h.logger != nil { + if w, ok := h.logger.Writer().(*os.File); ok { + w.Close() + } + } + h.logger = log.New(f, "", log.LstdFlags) + } + } + + if config.LogLevel > 0 { + h.loglevel = config.LogLevel + } + return nil, nil }