Bug 1123524

Summary: Don't add stream handler to root logger in library
Product: [Fedora] Fedora Reporter: Pavol Babinčák <pbabinca>
Component: packagedb-cliAssignee: Pierre-YvesChibon <pingou>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: kevin, lmacken, pingou, thozza
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: packagedb-cli-2.5-1.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-26 07:02:46 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:
Bug Depends On:    
Bug Blocks: 1114381    
Attachments:
Description Flags
Patch which fixes the bug none

Description Pavol Babinčák 2014-07-25 23:23:16 UTC
Description of problem:
Python module pkgdb2client configures logging with logging.basicConfig()[1]. Libraries which import this module need to unnecessary fix logging configuration. Otherwise any log messages are written to stderr.

Version-Release number of selected component (if applicable):
2.4

How reproducible:
Always

Steps to Reproduce:
1. $ python
>>> import logging
>>> import pkgdb2client
>>> import sys
>>> logger = logging.getLogger('myLogger')
>>> logger.setLevel(logging.DEBUG)
>>> ch = logging.StreamHandler(sys.stdout)
>>> ch.setLevel(logging.DEBUG)
>>> logger.addHandler(ch)
>>> logger.debug('test message')

Actual results:
On the stdout & stderr following messages are printed:
test message
DEBUG:myLogger:test message

Expected results:
Only message to stdout should be printed:
test message

Additional info:
Logging documentation describes[2] how considerate python libraries should be configured towards other libraries.

[1] https://docs.python.org/3.1/library/logging.html#logging.basicConfig
[2] https://docs.python.org/3.1/library/logging.html#library-config

Comment 1 Pavol Babinčák 2014-07-25 23:25:25 UTC
Created attachment 921094 [details]
Patch which fixes the bug

Patch with fix attached.

Comment 2 Pierre-YvesChibon 2014-07-26 07:02:46 UTC
Thanks for the catch and thanks for the patch :)

Comment 3 Jens Petersen 2014-07-30 02:23:07 UTC
*** Bug 1114381 has been marked as a duplicate of this bug. ***

Comment 4 Fedora Update System 2014-07-31 05:42:35 UTC
packagedb-cli-2.5-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/packagedb-cli-2.5-1.fc19

Comment 5 Fedora Update System 2014-07-31 05:42:42 UTC
packagedb-cli-2.5-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/packagedb-cli-2.5-1.el6

Comment 6 Fedora Update System 2014-07-31 05:42:47 UTC
packagedb-cli-2.5-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/packagedb-cli-2.5-1.fc20

Comment 7 Fedora Update System 2014-08-15 02:41:23 UTC
packagedb-cli-2.5-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2014-08-18 18:57:50 UTC
packagedb-cli-2.5-1.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2014-08-19 07:06:12 UTC
packagedb-cli-2.5-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Pavol Babinčák 2014-09-26 16:12:05 UTC
*** Bug 1120690 has been marked as a duplicate of this bug. ***