Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to pipe a debug configuration through another command?

Using PHPStorm 6/7 (or WebStorm I guess), is it possible to configure a debug session so that it understands and uses piping to have a more convenient display in the PHPStorm console? I'm working on a nodejs app that utilizes bunyan. I'd like for PHPStorm to be able to pretty print the debug output as it would if I launched the app from the terminal.

Here's an example config:

examle phpstorm debug config

But the command it's trying to run is:

/usr/local/bin/node --debug-brk=57073 app.js -vv 2>&1 "|" bunyan

If it wouldn't quote the pipe symbol, it might work, but I'm not sure.

like image 982
Justin Avatar asked Dec 28 '25 16:12

Justin


2 Answers

Pipes is a feature of the command line shell, PhpStorm doesn't use shell to start your configuration, so pipes and output redirection will not work.

Slightly related issues:

  • http://youtrack.jetbrains.com/issue/IDEA-103907
  • http://youtrack.jetbrains.com/issue/WEB-1933

You can probably hack some wrapper shell script around node and use it instead of the default node script. Your custom shell script can parse the arguments in its own way and perform piping. Not sure how well it will work.

like image 192
CrazyCoder Avatar answered Dec 31 '25 20:12

CrazyCoder


I found a bit a hacky solution for this problem that I also encountered. My solution doesn't include any configuration change in WebStorm. I simply created a piped output that is parsed with bunyan CLI tool which is loaded through node spawn child_process.

The code looks like this :

bunyan = require('bunyan');
logOptions = { name: 'myApp' };

// Activate this logger only for development and leave the original for production
if ( process.env.NODE_ENV === 'development' ) {
    spawn = require('child_process').spawn;
    bunyanCLI = spawn('bunyan', ['--color'], { stdio: ['pipe', process.stdout] });
    logOptions.stream = bunyanCLI.stdin;
} 

log = bunyan.createLogger(logOptions);
like image 36
drinchev Avatar answered Dec 31 '25 20:12

drinchev