Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save list of log handlers before removing them. #314

Merged
merged 1 commit into from
Jul 12, 2016

Conversation

psigen
Copy link
Member

@psigen psigen commented Jul 8, 2016

There is a bug in prpy.logger.initialize_logging where loggers are not fully removed by:
https://github.com/personalrobotics/prpy/blob/master/src/prpy/logger.py#L56

I think this is because the handlers property is doing odd stuff as it is iterated if removeHandler is called.

Here's an example of this code not working consistently:

# Supposedly remove all of the existing handlers.
base_logger = logging.getLogger()
print "Starting with these handlers: ", base_logger.handlers
for handler in base_logger.handlers:
    print "Removing: ", handler
    base_logger.removeHandler(handler)
print "Finishing with these handlers: ", base_logger.handlers
Starting with these handlers:  [<logging.StreamHandler object at 0x7fdb65567850>, <logging.StreamHandler object at 0x7fdb65567910>, <logging.StreamHandler object at 0x7fdb65567a10>, <logging.StreamHandler object at 0x7fdb65567ad0>]
# Removing:  <logging.StreamHandler object at 0x7fdb65567850>
# Removing:  <logging.StreamHandler object at 0x7fdb65567a10>
# Finishing with these handlers:  [<logging.StreamHandler object at 0x7fdb65567910>, <logging.StreamHandler object at 0x7fdb65567ad0>]

@mkoval mkoval merged commit 81e6070 into master Jul 12, 2016
@mkoval mkoval deleted the bugfix/logging_handler branch July 12, 2016 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants