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

Mechanism to log json requests and responses, to and from client #321

Closed
yyadavalli opened this issue Jun 28, 2018 · 5 comments
Closed

Mechanism to log json requests and responses, to and from client #321

yyadavalli opened this issue Jun 28, 2018 · 5 comments

Comments

@yyadavalli
Copy link
Contributor

We should provide a way to log the json at the boundary to make sure different clients are working correctly. It also helps debug a lot of client related issues.

@gabro
Copy link
Member

gabro commented Jun 28, 2018

I believe logs are already there, simply disabled since they have status trace.

@olafurpg
Copy link
Member

I think after we complete #318 it will be easier to programmatically set the log level based on a system property like -Dmetals.logger=trace. It's probably possible to do it with logback but I would prefer to invest in completing the migration to scribe first.

@yyadavalli
Copy link
Contributor Author

@gabro is there a way to enable them?

@olafurpg
Copy link
Member

olafurpg commented Jun 28, 2018 via email

@olafurpg
Copy link
Member

Fixed in #337. All incoming and outgoing JSON requests can now be seen by following instructions that are printed during startup of the server

info  Tracing is disabled for protocol LSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/olafurpg/Library/Caches/org.scalameta.metals/lsp.trace.json

If the trace file exists, then you can tail -f it or use less to see raw JSON payloads

{
  "jsonrpc": "2.0",
  "method": "build/taskFinish",
  "params": {
    "taskId": {
      "id": "1"
    },
    "eventTime": 1543340644550,
    "message": "Compiled \u0027test-workspace\u0027",
    "dataKind": "compile-report",
    "data": {
      "target": {
        "uri": "file:/Users/olafurpg/dev/metals/test-workspace/?id\u003dtest-workspace"
      },
      "errors": 0,
      "warnings": 0
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": "6",
  "result": {
    "statusCode": 1
  }
}

This works for both LSP and BSP communication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants