Bug 813098 - Debug messages from SDK are going to stdout.
Debug messages from SDK are going to stdout.
Status: CLOSED NOTABUG
Product: oVirt
Classification: Community
Component: ovirt-engine-sdk (Show other bugs)
unspecified
All All
unspecified Severity medium
: ---
: ---
Assigned To: Michael Pasternak
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-16 17:29 EDT by Jaroslav Henner
Modified: 2014-01-12 19:37 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-04-18 07:48:40 EDT
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)

  None (edit)
Description Jaroslav Henner 2012-04-16 17:29:45 EDT
Description of problem:
Debug messages from SDK are going to stdout:

if(DEBUG): print 'adding to collection: ' + collection + ', url: ' + url + ', add() method:\n' + add_method

that is not too good, because the user of the SDK may want to not print them to stdout or alter them a bit. Better to use `logging` module which powerful standard way to log in python.

There would have been some init. code:
import logging
LOGGER = logging.getLogger("ovirtsdk")

But then it is easy-peasy
LOGGER.debug('adding to collection: %s url: %s add() method:\n%s', collection, url, add_method)

the user/application should init the log, for example using
logging.basicConfig(level=logging.DEBUG)
or there is a way to read the logging config from file...

Version-Release number of selected component (if applicable):
ovirt-engine-sdk-1.6.4
Comment 1 Michael Pasternak 2012-04-18 06:52:18 EDT
mentioned debug prints belongs to code-generation and not a part of sdk,
therefore no user can see/use them
Comment 2 Jaroslav Henner 2012-04-18 07:10:55 EDT
It is not about the examples I provided:

When stdout is redirected to /dev/null, I'll get no output.
`--> python -c 'import ovirtsdk.api as api; api.API("https://jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443/", "***", "***", debug=True).clusters.get(name="Default")' > /dev/null

If not, I'll get the errors on console
`--> python -c 'import ovirtsdk.api as api; api.API("https://jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443/",  "***", "***", debug=True).clusters.get(name="Default")'            
send: 'GET /api/clusters?search=name%3DDefault HTTP/1.1\r\nHost: jh-rhsetup.rhev.lab.eng.brq.redhat.com:8443\r\nAccept-Encoding: identity\r\nContent-type: application/xml\r\nAuthorization: Basic dmRjYWRtaW5Acmhldi5sYWIuZW5nLmJycS5yZWRoYXQuY29tOjEyMzQ1Ng==\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: Apache-Coyote/1.1
header: Pragma: No-cache
header: Cache-Control: no-cache
header: Expires: Thu, 01 Jan 1970 01:00:00 CET
header: X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
header: Content-Type: application/xml
header: Content-Length: 841
header: Date: Wed, 18 Apr 2012 11:08:21 GMT

I think that is a proof that it is printing the debug messages to stdout. Which is not good.
Comment 3 Michael Pasternak 2012-04-18 07:48:40 EDT
this behaviour defined and implemented by python HTTPConnection spec.,
and out of my control,

also note: this is debug prints and not logs ..., in your implementation 
you can capture sdk stdio and redirect it to the file,

in general no sdk maintain own log as it's already done by the backend,
sdk only provide debugging capabilities and debug output can be redirected
to file if needed.

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