Bug 849917 - error messages shall be logged to stderr rather than to stdout
error messages shall be logged to stderr rather than to stdout
Status: NEW
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-tools (Show other bugs)
Development
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Ernie
MRG Quality Engineering
: Improvement
Depends On:
Blocks: 1082102
  Show dependency treegraph
 
Reported: 2012-08-21 04:34 EDT by Petr Matousek
Modified: 2014-11-09 17:40 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 1082102 (view as bug list)
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
proposed patch (3.78 KB, patch)
2014-03-28 09:47 EDT, Petr Matousek
eallen: review-
Details | Diff

  None (edit)
Description Petr Matousek 2012-08-21 04:34:59 EDT
Description of problem:

Exceptions and error messages are logged to stdout instead of stderr.
The stream stdout is buffered. This can produce unexpected results, especially with debugging output. 

Version-Release number of selected component (if applicable):
qpid-tools-0.14-5

How reproducible:
100%

Steps to Reproduce:
1. run management tools without broker running
2. realize that the error message was logged to stdout
  
Actual results:
Exceptions and error messages are logged to stdout

Expected results:
Exceptions and error messages are logged to stderr

Additional info:

# service qpidd status
qpidd is stopped
# qpid-config 2>/dev/null
Failed: error: (111, 'Connection refused')
# service qpidd start
Starting Qpid AMQP daemon:                                 [  OK  ]
# qpid-config -a amqps://localhost:5671 --ssl-certificate=cert.pem 2>/dev/null
Failed: Exception: Client authentication not supported by this version.
Comment 3 Petr Matousek 2014-03-28 09:47:51 EDT
Created attachment 879838 [details]
proposed patch

note: the patch also removes extra trailing spaces
Comment 5 Ernie 2014-03-28 10:54:22 EDT
Comment on attachment 879838 [details]
proposed patch

This works well for qpid-config. We'll need to make similar changes to the other python tools.

You might consider using the new print function syntax:
from __future__ import print_function
and adding a function:
def print_stderr(str):
    print(str, file=sys.stderr)

and then calling print_stderr() whenever you explicity want to print to stderr. 
The pros of doing this are
- It is future-proof in that it is the recommended way for python 2.x and 3.x
- Calling a function named print_stderr is self-documenting

The big con of doing this is that all print statements would need to be changed to print functions. 

See http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function
Comment 6 Justin Ross 2014-03-28 11:41:27 EDT
(In reply to Ernie from comment #5)
> Comment on attachment 879838 [details]
> proposed patch
> 
> This works well for qpid-config. We'll need to make similar changes to the
> other python tools.
> 
> You might consider using the new print function syntax:
> from __future__ import print_function
> and adding a function:
> def print_stderr(str):
>     print(str, file=sys.stderr)
> 
> and then calling print_stderr() whenever you explicity want to print to
> stderr. 
> The pros of doing this are
> - It is future-proof in that it is the recommended way for python 2.x and 3.x
> - Calling a function named print_stderr is self-documenting
> 
> The big con of doing this is that all print statements would need to be
> changed to print functions. 
> 
> See http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function

Unfortunately, I don't think we can use print_function.  It appears to have become available in python 2.6, and el5 is python 2.4.
Comment 7 Justin Ross 2014-03-28 12:07:58 EDT
(In reply to Justin Ross from comment #6)
> (In reply to Ernie from comment #5)
> > Comment on attachment 879838 [details]
> > proposed patch
> > 
> > This works well for qpid-config. We'll need to make similar changes to the
> > other python tools.
> > 
> > You might consider using the new print function syntax:
> > from __future__ import print_function
> > and adding a function:
> > def print_stderr(str):
> >     print(str, file=sys.stderr)
> > 
> > and then calling print_stderr() whenever you explicity want to print to
> > stderr. 
> > The pros of doing this are
> > - It is future-proof in that it is the recommended way for python 2.x and 3.x
> > - Calling a function named print_stderr is self-documenting
> > 
> > The big con of doing this is that all print statements would need to be
> > changed to print functions. 
> > 
> > See http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function
> 
> Unfortunately, I don't think we can use print_function.  It appears to have
> become available in python 2.6, and el5 is python 2.4.

Eeks, my mistake.  This is targeted for versions of RHEL > 5, so Ernie's advice stands.
Comment 8 Petr Matousek 2014-03-28 12:43:43 EDT
Actually it shall be addressed in both 2.x and 3.x, so leaving this bug tracking 2.x defect and cloning for 3.x.

Note You need to log in before you can comment on or make changes to this bug.