Follow-up from #638536: Return a non-zero exit status on errors ...
dmitrig01 says drush make is just calling drush_log('foo', 'error'). To be a good CLI citizen, when drush is logging 'error', it should write it to stderr, not stdout.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | drush-log-to-stderr.patch | 1.51 KB | greg.1.anderson |
Comments
Comment #1
moshe weitzman commentedI'll let adrian chime in here. Meanwhile, an equivalent way to log errors that is more clear is drush_set_error('foo')
Comment #2
moshe weitzman commentedFYI, nothing goes to stdout except errors unless you have an elevated debug level. are you running with --verbose (-v) or --debug (-d)?
Comment #3
dwwRegardless of -v or -d, errors belong in stderr. That's how UNIX has worked for decades, for good reason. ;) Otherwise, you can't pipe things into each other or the payload gets mixed in with the errors/warnings.
Comment #4
dmitrig01 commentedI did mean drush_set_error
Comment #5
moshe weitzman commentedcomments?
Comment #6
greg.1.anderson commentedI agree that stderr should be preferred to stdout for all log, error and debug messages.
Comment #7
anarcat commentedI agree everything should go to stderr, but if things are going to stdout now (which i find odd), Aegir will need some patching.
I think this change should be done before 3.0 gets shipped.
Comment #8
JacobSingh commentedI need this too..
How should this be implemented? Should we output exactly the same format? It's not very parsable, but perhaps that doesn't matter?
for now, I just chucked this in my drush_log
But obviously, we should do better.
Best,
J
Comment #9
torotil commented+1 for dumping errors into stderr. What's the problem with in implementing this?
Comment #10
moshe weitzman commentedNo problem. Someone needs to contribute a patch.
Comment #11
greg.1.anderson commentedYeah, I've got this working; I'll post a patch later.
Comment #12
greg.1.anderson commentedSwitching drush_log to stderr required only a couple trivial changes. As an added bonus, this patch also fixes a typo in $green. Previously, $green rendered as yellow. Adjusted per http://rtfm.etla.org/xterm/ctlseq.html; "32: Set foreground color to Green", "33 Set foreground color to Yellow".
Comment #13
moshe weitzman commentedLooks good to me. Could we add some docs about how to use this. Maybe a script in examples? Otherwise, a link to STDERR usage somewhere on the internets.
I'd love some +1 from the Aegir folks.
Comment #14
owen barton commentedLooks good to me too - basically we just want drush_print output (i.e. content, not log output) to go to stdout by default, which I think is what this does. I agree $handle usage could use some docs.
Comment #15
greg.1.anderson commentedI did a couple more tests to convince myself that the output and data structures in backend invoke were not affected, and as I had presumed, it came out unchanged. Committed with an additional comment for $handle in drush_print.