Red Hat Bugzilla – Bug 813098
Debug messages from SDK are going to stdout.
Last modified: 2014-01-12 19:37:11 EST
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:
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
or there is a way to read the logging config from file...
Version-Release number of selected component (if applicable):
mentioned debug prints belongs to code-generation and not a part of sdk,
therefore no user can see/use them
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.
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.