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

chore: add tracing #70

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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