rubberduck-ai / rubberduck-vscode

Use AI-powered code edits, explanations, code generation, error diagnosis, and chat in Visual Studio Code with the official OpenAI API.
https://marketplace.visualstudio.com/items?itemName=Rubberduck.rubberduck-vscode
MIT License
602 stars 75 forks source link

Improve logs #49

Closed nicoespeon closed 1 year ago

nicoespeon commented 1 year ago

To help figure out what's going on with bugs like #45 I added a bunch of logs around the OpenAI calls to generate completion.

I introduced a Logger that would handle a specific log level. I went for a basic implementation, but we could totally replace the current adapter with Pino (implementation details won't impact the client code).

debug logs

Log level can be set in settings and defaults to "info" which will show up the ERROR logs I added: settings

Note: I wish there were some colors in the output. But to do so requires defining a grammar and giving that to VS Code, so I decided to postpone this for later. My goal was to get some more logs and be able to debug more easily.