Bug 813098
| Summary: | Debug messages from SDK are going to stdout. | ||
|---|---|---|---|
| Product: | [Retired] oVirt | Reporter: | Jaroslav Henner <jhenner> |
| Component: | ovirt-engine-sdk | Assignee: | Michael Pasternak <mpastern> |
| Status: | CLOSED NOTABUG | QA Contact: | |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | unspecified | CC: | acathrow, bazulay, dyasny, iheim, mgoldboi, ykaul |
| Target Milestone: | --- | Keywords: | Reopened |
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2012-04-18 11:48:40 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
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. |
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