Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments to direct logs to various locations #3665

Merged
merged 3 commits into from
Jun 23, 2023
Merged

Conversation

michaelpj
Copy link
Collaborator

This adds arguments to HLS to allow the user to select whether to send logs to any or all of:

  • a file
  • stderr
  • the client

Importantly, we can toggle off the default stderr logging, so the vscode extension can turn it off to avoid the double logging that arises from logging to both the client and stderr.

I've set the default to not log to the client. This is a change of behaviour (today we log to the client by default), but I think it gives the best experience by default, since most clients do show stderr output somewhere, and then we probably want to make a case-by-case decision on whether to use the client logging instead.

@michaelpj michaelpj requested a review from fendor June 16, 2023 14:16
@michaelpj michaelpj requested a review from pepeiborra as a code owner June 16, 2023 14:16
& cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions . fst)
-- do not log heap stats to the LSP log as they interfere with the
-- ability of lsp-test to detect a stuck server in tests and benchmarks
& if argsTesting then cfilter (not . heapStats . snd . payload) else id
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this any more since we're not logging to the client by default.

Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, loving that change

@fendor
Copy link
Collaborator

fendor commented Jun 16, 2023

The logs are suddenly so clean and easy to read 🤯

@michaelpj michaelpj force-pushed the mpj/log-locations branch from 187003c to 208ccea Compare June 18, 2023 15:51
@fendor fendor added merge me Label to trigger pull request merge and removed merge me Label to trigger pull request merge labels Jun 18, 2023
@fendor
Copy link
Collaborator

fendor commented Jun 18, 2023

Ah, some tests actually use the logs

@michaelpj michaelpj force-pushed the mpj/log-locations branch from 9553008 to 88f0381 Compare June 23, 2023 15:29
This adds arguments to HLS to allow the user to select whether to send
logs to any or all of:
- a file
- stderr
- the client

Importantly, we can toggle off the default stderr logging, so the vscode
extension can turn it off to avoid the double logging that arises from
logging to both the client and stderr.

I've set the default to _not_ log to the client. This is a change of
behaviour (today we log to the client by default), but I think it gives
the best experience by default, since most clients do show stderr output
somewhere, and then we probably want to make a case-by-case decision on
whether to use the client logging instead.
@michaelpj michaelpj force-pushed the mpj/log-locations branch from 88f0381 to fc13e05 Compare June 23, 2023 15:44
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@fendor fendor added the merge me Label to trigger pull request merge label Jun 23, 2023
@mergify mergify bot merged commit 53604eb into master Jun 23, 2023
@@ -138,12 +140,40 @@ arguments plugins = GhcideArguments
<> help "Sets the log level to Debug, alias for '--log-level Debug'"
)
)
<*> optional (strOption
(long "logfile"
<> short 'l'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest keeping the short form for at least one release cycle.
I just got bitten by this, and had to re-configure my emacs to use it

  :custom
  (lsp-haskell-server-args `("-d" "--log-file" ,lsp-haskell-server-log-file))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, that was an oversight, I meant to leave the old options in! I left the old spelling but missed the short option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I don't think leaving it in for a release cycle helps all that much: it just means that people will be surprised by it one cycle later. It's only useful if you're switching between and old and new version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(... then why am I leaving the old spelling in? I guess we could just never remove it)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one release cycle thing is so you could update clients to use the new one, but if people still ran an older server it would still work. Then in time get rid of it.
To me, keeping the short form is the best option

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fendor fendor mentioned this pull request Aug 8, 2023
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants