示例#1
0
 def test_formats(self):
     """
     The passed stack is formatted.
     """
     assert _format_stack(sys._getframe()).startswith(
         "Stack (most recent call last):\n"
     )
示例#2
0
 def test_formats(self):
     """
     The passed stack is formatted.
     """
     assert _format_stack(sys._getframe()).startswith(
         "Stack (most recent call last):\n"
     )
示例#3
0
 def test_no_trailing_nl(self, monkeypatch):
     """
     Trailing newlines are snipped off but if the string does not contain
     one nothing is removed.
     """
     from structlog._frames import traceback
     monkeypatch.setattr(traceback, "print_stack",
                         lambda frame, file: file.write("foo"))
     assert _format_stack(sys._getframe()).endswith("foo")
示例#4
0
 def test_no_trailing_nl(self, monkeypatch):
     """
     Trailing newlines are snipped off but if the string does not contain
     one nothing is removed.
     """
     from structlog._frames import traceback
     monkeypatch.setattr(
         traceback, "print_stack",
         lambda frame, file: file.write("foo")
     )
     assert _format_stack(sys._getframe()).endswith("foo")
示例#5
0
    def findCaller(self, stack_info=False, stacklevel=1):
        """
        Finds the first caller frame outside of structlog so that the caller
        info is populated for wrapping stdlib.

        This logger gets set as the default one when using LoggerFactory.
        """
        f, name = _find_first_app_frame_and_name(["logging"])
        if stack_info:
            sinfo = _format_stack(f)
        else:
            sinfo = None
        return f.f_code.co_filename, f.f_lineno, f.f_code.co_name, sinfo
示例#6
0
文件: stdlib.py 项目: ddorstijn/Game
 def findCaller(self, stack_info=False):
     """
     Finds the first caller frame outside of structlog so that the caller
     info is populated for wrapping stdlib.
     This logger gets set as the default one when using LoggerFactory.
     """
     f, name = _find_first_app_frame_and_name(['logging'])
     if PY3:  # pragma: nocover
         if stack_info:
             sinfo = _format_stack(f)
         else:
             sinfo = None
         return f.f_code.co_filename, f.f_lineno, f.f_code.co_name, sinfo
     else:
         return f.f_code.co_filename, f.f_lineno, f.f_code.co_name
示例#7
0
 def test_returns_str(self):
     """
     Always returns a native string.
     """
     assert isinstance(_format_stack(sys._getframe()), str)
示例#8
0
 def test_returns_str(self):
     """
     Always returns a native string.
     """
     assert isinstance(_format_stack(sys._getframe()), str)
示例#9
0
 def __call__(self, logger, name, event_dict):
     if event_dict.pop('stack_info', None):
         event_dict['stack'] = _format_stack(
             _find_first_app_frame_and_name()[0])
     return event_dict
示例#10
0
 def __call__(self, logger, name, event_dict):
     if event_dict.pop('stack_info', None):
         event_dict['stack'] = _format_stack(
             _find_first_app_frame_and_name()[0]
         )
     return event_dict
示例#11
0
 def test_formats(self):
     assert _format_stack(sys._getframe()).startswith(
         'Stack (most recent call last):\n'
     )
示例#12
0
 def test_returns_str(self):
     assert isinstance(_format_stack(sys._getframe()), str)