diff options
author | Ashley Camba <ashwoods@gmail.com> | 2017-08-08 16:05:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-08 16:05:45 +0200 |
commit | f2a613a2a3c18ccfd8b3337e5528fdc9e434e743 (patch) | |
tree | f3bbc4e5da55f7ce5371104f5c1a77fc67cef663 | |
parent | 1e52542261a5c5846f3209e72a72b73bf44c9d1b (diff) | |
parent | 57d2fc58006ee13967fda38801e3d85c05d077e1 (diff) | |
download | raven-f2a613a2a3c18ccfd8b3337e5528fdc9e434e743.tar.gz |
Merge pull request #1053 from solute/breacrumbs-logging-srcfile-none2
breadcrumbs: Check logging._srcfile in _wrap_logging_method
-rw-r--r-- | raven/breadcrumbs.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/raven/breadcrumbs.py b/raven/breadcrumbs.py index 812e96f..3980b88 100644 --- a/raven/breadcrumbs.py +++ b/raven/breadcrumbs.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +import os import time import logging from types import FunctionType @@ -154,6 +155,12 @@ def _wrap_logging_method(meth, level=None): code = get_code(func) + logging_srcfile = logging._srcfile + if logging_srcfile is None: + logging_srcfile = os.path.normpath( + logging.currentframe.__code__.co_filename + ) + # This requires a bit of explanation why we're doing this. Due to how # logging itself works we need to pretend that the method actually was # created within the logging module. There are a few ways to detect @@ -183,7 +190,7 @@ def _wrap_logging_method(meth, level=None): 'args': ', '.join(args), 'fwd': fwd, 'level': level, - }, logging._srcfile, 'exec'), logging.__dict__, ns) + }, logging_srcfile, 'exec'), logging.__dict__, ns) new_func = ns['factory'](meth, _record_log_breadcrumb) new_func.__doc__ = func.__doc__ |