4

Intro: Hi folks, I'd like to ask some questions about extension developing. I'd like to create a remote lua debuger extension (for linux user, haven't found any working lua debugger). When I touch the launch button, the debug server should be started to listen (on e.g. 0.0.0.0:8723) for waiting debugger connection. And on the other side sould communicate through the DAP (debug adapter protocol) with vscode.
Problem: I'm starting to implement the my own debuger extension... But I am new in this topic and with Node.js also. My question is: How can I log (or debug) my LoggingDebugSession (where the DAP is implemented)?

I looked at the MockDebug extension example project.And tried to rewrite...

Try to log into console, my file luaDebugSession.ts:

export class LuaDebugSession extends LoggingDebugSession {

    public constructor() {
        super("remote-lua-debug-log.txt"); 
        this.sendEvent(new OutputEvent("Try to log"));
        console.log("Try log into console")
    }

    protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void {

        this.sendEvent(new OutputEvent("Try to log 2"));
        console.log("Try log into console 2")

        // do something

        this.sendEvent(new InitializedEvent());
    }

    // next code...
}

In console should be the logged output.

Jan
  • 463
  • 1
  • 5
  • 15
  • 2
    I needed the exact thing, and found this answer: https://stackoverflow.com/a/44196165/1974224, it helped me a lot, maybe it will help you too :) – Cristik May 21 '20 at 17:37

1 Answers1

1

It will depend on how you start the debug adapter. If you run it in your own code, the console.log will log the information to the terminal console which is activated.

But if it is started by vscode, it will be an independent node process. It can't access the console you use now. So you can write the information to the log file or another method to log it.

Wish it can help you a little.

sfilata
  • 15
  • 5