Skip to content

Show stdout instead of stderr? #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexislefebvre opened this issue Oct 3, 2018 · 1 comment
Open

Show stdout instead of stderr? #62

alexislefebvre opened this issue Oct 3, 2018 · 1 comment

Comments

@alexislefebvre
Copy link

alexislefebvre commented Oct 3, 2018

Here is my script:

tasks:
    - name: phpqa
      parallel-tasks: 
        - name: PHPStan
          cmd: docker run -t -w /project jakzal/phpqa:alpine phpstan analyse --no-progress EXAMPLE

Here is the output:

Running /home/alexis/scripts/phpqa.yaml
    • phpqa                     
      ╰─ PHPStan                   Exited with error (1)
      100.00% Complete  Tasks[1/1] See log for details (/dev/null) Runtime[00:00:00]
 ...Some tasks failed, see below for details.

⏺ Failed task: PHPStan
  ├─ command: docker run -t -w /project jakzal/phpqa:alpine phpstan analyse --no-progress EXAMPLE
  ├─ return code: 1
  ╰─ stderr: 

There's no output.


I add 1>&2 to the end of the command.

Here is the output:

$ bashful run ~/scripts/phpqa.yaml
Running /home/alexis/scripts/phpqa.yaml
    • phpqa                     
      ╰─ PHPStan                   Exited with error (1)
      100.00% Complete  Tasks[1/1] See log for details (/dev/null)    Runtime[00:00:01]
 ...Some tasks failed, see below for details.

⏺ Failed task: PHPStan
  ├─ command: docker run -t -w /project jakzal/phpqa:alpine phpstan analyse --no-progress EXAMPLE 1>&2
  ├─ return code: 1
  ╰─ stderr:  ------ -------------------------------------- 
  Line   EXAMPLE                               
 ------ -------------------------------------- 
         Path /project/EXAMPLE does not exist  
 ------ -------------------------------------- 

                                                          
 [ERROR] Found 1 error                                                                          

I have to use 1>&2 because the command outputs result on stdout instead of stderr.

Is it possible to display stdout instead of strerr id a command fails? Could it be configurable for each command?

@wagoodman
Copy link
Owner

It is possible to do this, but it already is questionable to buffer the stderr as it is. That is, if there is a substantial amount of stdout from an application (which is more typically expected than a lot of stderr output) then you'l start running out of memory for tracking the output for several tasks that have a lot of output.

That being said, it is certainly possible and there are some simple steps that can be taken to capturing "just enough" output (such as a circular buffer like this: https://github.com/armon/circbuf). We could add options for capturing either or both stdout and stderr on failure:

tasks:
    - name: phpqa
      parallel-tasks: 
        - name: PHPStan
          cmd: ...
          stderr-on-failure: false
          stdout-on-failure: true

or globally for all tasks:

config:
  stderr-on-failure: false
  stdout-on-failure: true
tasks:
    - name: phpqa
      parallel-tasks: 
        - name: PHPStan
          cmd: ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants