Skip to content

[Suggestion] Use File based logger #15

Closed

Description

@HerringtonDarkholme

Hi, thanks for bringing us Python Language Server!

I'm using it with LanguageClient_neovim. And I'm debugging some issue with PLS.
Usually, the server is opened by language client. Users cannot control where language server can log.

PLS now logs to stderr by default. It would be helpful if PLS can log to a file. So editor users can inspect log independent of language client's behavior. For example, logging to /tmp/LanguageServer.log by default and file path can be configured by command line argument.

Thank you!

Activity

  1. gatesn commented on Mar 5, 2017

    @gatesn
    Contributor

    Will look to implement something similar to here: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/

    Sensible defaults but read logging config from file if it's available

  2. HerringtonDarkholme commented on Mar 7, 2017

    @HerringtonDarkholme
    Author

    Actually this problem is more serious. autozimu/LanguageClient-neovim#21

    It seems writing to stderr blocks writing to stdout.

  3. gatesn commented on Mar 7, 2017

    @gatesn
    Contributor

    So the problem, as you pointed out, is that languageClient-neovim sets stderr=PIPE. What is happening is the client blocks waiting to read from stdout, Pyls fills up stderr buffer and blocks waiting to write to stderr and we end up in deadlock.

    See here for more explanation:
    http://stackoverflow.com/questions/1180606/using-subprocess-popen-for-process-with-large-output

    What languageClient-neovim should be doing is use select to read off both stdout and stderr and then throwing away stderr if it doesn't think its relevant. Alternatively it could set stderr=None to just drop it entirely, it could redirect it to appear on the client's stderr, or it could pass in a file object to redirect stderr to disk.

    I agree that Pyls should have more configurable logging and will work on implementing that, but it's not in any language server contract that logs cannot be written to stderr.

    Equally changing the log level isn't sufficient as in the case there is a lot of ERROR messages it will still hang! Just happening less frequently.

    So I think the solution here is for us to support configurable logging, and to make things easy for clients maybe a command line switch to redirect stderr to a file, but also for languageClient-neovim to properly handle stderr.

  4. HerringtonDarkholme commented on Mar 7, 2017

    @HerringtonDarkholme
    Author

    I don't think LanguageClient is the same as the stackoverflow question.

    Actually PYLS blocks at writing to stdout, not stderr. Recorded here autozimu/LanguageClient-neovim#21

    Source:
    https://github.com/palantir/python-language-server/blob/master/pyls/jsonrpc.py#L155

  5. gatesn commented on Mar 7, 2017

    @gatesn
    Contributor

    @HerringtonDarkholme would be great to get your thoughts on this PR as a solution: #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions