I've a project that i'm using Bunyan logger as logger agent. But the Bunyan logs with the json format the debug texts, and this make difficult to read the output:
But Bunyan provides a CLI tool to humanize the log that converts the JSON to a readable text:
What I want's is create an extension to enable Bunyan console format to the Debug output text, automatic transforming the json output to debug text. But in VSCode extension development API I couldn't find any reference to manipulate debug console.
I if can manipulate de Debug console message, I could return te messages well formatted as Bunyan format.
So my question is if have some documentation to manipulate debug console messages or how i can work with debug console messages in my vscode extension.
I have found the answer by myself. I can do this simply changing my Debugger configurations, setting args and console type as the follow:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/app.js",
"cwd": "${workspaceRoot}",
"args": [
"|",
"bunyan"
],
"console": "integratedTerminal"
}
]
}
Related
According to documentation, I should be able to get my program output to display in the Integrated debug console instead of in the Integrated terminal with:
"programOutput": true in launch.json
In the simplest hello world C program on linux with vscode version 1.75.1, this just doesn't work. Both stderr, and stdout go to the integrated terminal.
By the way, the reason I want this to work is because I want to use the filter line to specify which output lines to show and which to hide.
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
...
...
"externalConsole": false,
"logging": {
"programOutput": true
},
I am using R Debugger in Vscode to develop an RShiny app while using SSH to connect to the remote.
My launch.json file looks like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "R-Debugger",
"name": "Launch R-Workspace",
"request": "launch",
"debugMode": "workspace",
"workingDirectory": "", // If I put my actual path here, it changes nothing
"allowGlobalDebugging":true
}
]
}
For the purposes of this topic, I have these folders/files:
src/www/uis
src/server.R
I set breakpoints in files within src/www/uis as well as within src/server.R.
When I use Launch R-Workspace, the breakpoints at src/www/uis will trigger but within src/server.r they turn into "unverified breakpoints".
What I've tried:
Reading through similar questions and findings answers that did not seem relevant. Reading through the documentation where I did not see anything useful to me.
Any insight?
Thanks
I would like to debug an APP and need to pass a in-line json as arg.
I did the following:
"configurations": [
{
"name": "app DEV",
"program": "lib/main.dart",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=APP_BACKENDS={[{\"id\":\"default\",\"url\":\"https://localhost\",\"port\": \"8080\"},]}",
]
}
but the APP_BACKENDS const value is getting stripped in the first comma. lock the print of it: {[{"id":"default"
just to be clear. that is the way I'm getting the value I've printed:
static const _APP_BACKENDS =
String.fromEnvironment('APP_BACKENDS', defaultValue: '{}');
After going through a lot of links and reading, finally I found a GitHub issue https://github.com/microsoft/vscode/issues/98471 which solved my similar problem. If you go through the link and read the second last comment it explains the things regarding shell quoting.
"configurations": [
{
"name": "app DEV",
"program": "lib/main.dart",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=APP_BACKENDS={[{\"id\":\"default\",\"url\":\"https://localhost\",\"port\": \"8080\"},]}",
],
"argsExpansion": "none"
}
"argsExpansion": "none" after adding this to my launch.json file I was able to run the code without adding extra \ or spaces as mentioned in other answers. I tried searching for this configuration in vscode docs but did not find any reference, however it worked for me.
I had the same issue - trying to pass a json string as a command line arg to a python script. Works fine from shell, but couldn't do the same from launch.json. VS Code was intepreting the commas as multiple arguments and passing multiple -b args into my program (4x separate -b args in my case).
Answer: add a space " " to the end of the arg value.
I fail to understand why this works, but it does. Note I'm single-slash escaping the double-quotes.
{
"name": "Test my python code",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"-r=/store/purchase",
"-b={\"items\":[\"cake\",\"coffee\",\"toilet roll\",\"masks\"]} "
],
"console": "integratedTerminal"
},
After reading this documentation: Launch JSON Reference, specifically
this reference, I got to know that, you need to use \\\ to achieve what you want. For example. In the documentation only this is given
JSON array of command-line arguments to pass to the program when it is launched. Example ["arg1", "arg2"]. If you are escaping characters, you will need to double escape them. For example, ["{\\\"arg1\\\": true}"] will send {"arg1": true} to your application
So, after looking at this, you must pass your JSON to your args in a proper format
args: [
"--dart-define=APP_BACKENDS={[{\\\"id\\\":\\\"default\\\",\\\"url\\\":\\\"https://localhost\\\",\\\"port\\\": \\\"8080\\\"}]}"
]
This will do your job!
With the right debug config file I can make VSCode run the currently focussed file through Mocha. However, I find it frustrating that if I am working on the actual code, rather than the spec file and I press F5, it tries to run the actual code as a spec file through Mocha.
So, my question is; given a file structure like this:
Folder
File.js
File.spec.js
And a debug config (.vscode/launch.json) like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Unit Tests: Current File",
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
"cwd": "${workspaceRoot}",
"args": [
"-u", "tdd",
"--timeout=999999",
"--colors",
"--opts", "${workspaceRoot}/mocha.opts",
"${file}" // I want to make this dynamic
],
}
]
}
Is it possible to get VSCode to debug the spec file whether the spec file (File.spec.js) or it's subject (File.js) are selected?
You can introduce a new dynamic variable by writing a simple extension that just defines one command, e.g. a smartFile command.
Then you can refer to that command in your launch config as ${command:smartFile}.
For the implementation of the command you can use everything available in VS Code extension API. So you can not only calculate a path based on your folder structure, but you can even pop-up UI. E.g. you could use QuickPick to select a test case from the list of all tests.
I am running Node.js in VS Code. I see output of console.log in the Debug Window.
Where does process.stdout.write go to? I can't find it in the Debug Console or any of the Output windows.
My launch.json is simply this:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/job.js"
}
]
}
Looking at issues with process.stdout.write the suggested fixes are adding these to your launch config:
"console": "internalConsole",
"outputCapture": "std",
Especially the outputCapture entry is important.
Make sure the Debug Console is visible:
Ctrl + Shift + Y
Can you try to add "console": "internalConsole" to your config and see if it works?
As per the docs these are the available options for the console:
console - what kind of console to use, for example, internalConsole,
integratedTerminal, externalTerminal