Skip to content

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