-
I am trying to add a logger to my langium project. I implemented the following class which works when I call it from another file in the console.
When I call my logger function from my main.ts file and just start my program, it doesn't work.
I also tried logging from other points in my program, but there also nothing happens. What is the correct way and the correct place to call such a function, so that I can use it throughout my whole application? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @so195, Can you provide a reproducible example? Note that language servers are not allowed to write to the normal stdio console (they get re-routed instead), as the stdio channel is usually used by the language client to transfer messages. |
Beta Was this translation helpful? Give feedback.
Thanks for the code! However, I cannot reproduce your issue, as the library correctly logs the data to a file (in the open VS Code workspace, since it's the
cwd
of the vscode extension).You might want to be a bit more specific about the filepath you're using. Maybe something like
__dirname + '/log.log'
instead to ensure that the log is created in the same directory where the language server is located?Note that you can still write to
console.log
, but the log is rerouted to a different channel - when running in vscode, it will…