Skip to content

Commit

Permalink
chore: add tracing (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-jeffery authored Sep 28, 2023
1 parent d1c7d7a commit 2f448cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@
"main": "./client/out/extension.node",
"browser": "./client/out/extension.browser",
"contributes": {
"configuration": [
{
"id": "openfga-vscode",
"title": "OpenFGA VS Code",
"properties": {
"openfgaLanguageServer.trace.server": {
"type": "string",
"scope": "window",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Traces the communication between VS Code and the openfga language server."
}
}
}
],
"languages": [
{
"id": "openfga",
Expand Down
14 changes: 13 additions & 1 deletion server/src/server.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import {
import { validator, errors } from '@openfga/syntax-transformer';

export function startServer(connection: _Connection) {

console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);

// Create a simple text document manager.
const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);

Expand All @@ -30,6 +34,9 @@ export function startServer(connection: _Connection) {
let hasDiagnosticRelatedInformationCapability = false;

connection.onInitialize((params: InitializeParams) => {

console.log("Initialize openfga language server");

const capabilities = params.capabilities;

// Does the client support the `workspace/configuration` request?
Expand Down Expand Up @@ -62,6 +69,11 @@ export function startServer(connection: _Connection) {
}
};
}

console.log("hasConfigurationCapability: " + hasConfigurationCapability);
console.log("hasWorkspaceFolderCapability: " + hasWorkspaceFolderCapability);
console.log("hasDiagnosticRelatedInformationCapability: " + hasDiagnosticRelatedInformationCapability);

return result;
});

Expand Down Expand Up @@ -137,7 +149,7 @@ export function startServer(connection: _Connection) {

connection.onDidChangeWatchedFiles(_change => {
// Monitored files have change in VSCode
connection.console.log('We received an file change event');
console.log('We received an file change event');
});

// This handler provides the initial list of the completion items.
Expand Down

0 comments on commit 2f448cf

Please sign in to comment.