Dereference weak references on loggers and handlers.

#1 Merged
Repository
santtu
Branch
default
Repository
trustcentric
Branch
default
Author
  1. Santeri Paavolainen
Reviewers
Description

It seems that either recent python version or something deep inside django means that logging._handlerList returns a list with weakrefs to the actual handlers (same for loggers).

This patch contains a dereferer, which is used to turn weakrefs back to realrefs, if found.

Comments (6)

  1. Santeri Paavolainen author

    We're using Python 2.7.2/2.7.3 and Django 1.4.0.

    There's no error or stack trace -- just that request logging does not work.

    When _find_filterer_with_filter iterates over the handler/logger list (which contains weakrefs), getattr on "filters" will return an empty list. Thus, it won't find any filters with RequestFilter in them, and thus won't add per-request to those either. This will cause the initial RequestFilter to be applied, which doesn't have a request object and all fields will be replaced with the default "-" value.

    Looking at Python repository, here's the relevant information:

    The issue was closed in 2010, so I guess it is in any Python version >= 2.7.