ioBroker / dev-docs

Developer documentation
5 stars 4 forks source link

Debugging with vsCode / console output missing [Solution] #35

Open mcm1957 opened 2 years ago

mcm1957 commented 2 years ago

When using vsCode to debug an adapter there is a chance that console output via adapter.log.xxx is missing while normal console.log output is visible. This is a "bug" (or bad feature ?) of vsCode in conjunction with winstonjs which is sused as trasport by ioBorker logger code.

Links to the problem: https://github.com/winstonjs/winston/issues/1544 https://github.com/microsoft/vscode/issues/69959

The key to the solution is the line "outputCapture": "std", added to vsCode's launch.json

So with the following launch.json (only the important art added below) vsCode outputs every logger message (adapter.log.xxx) to the vsCode debugging output window:

    "configurations": [
        {
            "name": "Launch normal",
            "program": "${workspaceFolder}/main.js",
            "args": ["--instance", "0", "--force", "--logs", "--debug"],
            "request": "launch",
            "stopOnEntry": true,
            "console": "internalConsole",
            "outputCapture": "std",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node"
        },  

Note that iob paramaters --logs (with s :-) ) and --debug should be used to control output of iobs logger.