Skip to content

Commit

Permalink
Fix for #198
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 18, 2022
1 parent 5f80b37 commit c0d4ee1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions reportportal_client/logs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def __init__(self, name, level=0):
"""
super(RPLogger, self).__init__(name, level=level)

def _log(self, level, msg, args,
exc_info=None, extra=None, stack_info=False, attachment=None, **kwargs):
def _log(self, level, msg, args, exc_info=None, extra=None,
stack_info=False, attachment=None, **kwargs):
"""
Low-level logging routine which creates a LogRecord and then calls.
Expand All @@ -60,7 +60,8 @@ def _log(self, level, msg, args,
fn, lno, func = self.findCaller()
else:
if 'stacklevel' in kwargs:
fn, lno, func, sinfo = self.findCaller(stack_info, kwargs['stacklevel'])
fn, lno, func, sinfo = \
self.findCaller(stack_info, kwargs['stacklevel'])
else:
fn, lno, func, sinfo = self.findCaller(stack_info)

Expand Down
6 changes: 4 additions & 2 deletions tests/logs/test_rp_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def test_log_level_filter(handler_level, log_level, expected_calls):


@pytest.mark.skipif(sys.version_info < (3, 8),
reason='"stacklevel" introduced in Python 3.8, so not actual for earlier versions')
reason='"stacklevel" introduced in Python 3.8, so not '
'actual for earlier versions')
@mock.patch('reportportal_client.logs.logging.Logger.handle')
def test_stacklevel_record_make(logger_handler):
logger = RPLogger('test_logger')
logger.error('test_log', exc_info=RuntimeError('test'), stack_info=inspect.stack(), stacklevel=2)
logger.error('test_log', exc_info=RuntimeError('test'),
stack_info=inspect.stack(), stacklevel=2)
record = verify_record(logger_handler)
assert record.stack_info.endswith('return func(*newargs, **newkeywargs)')

0 comments on commit c0d4ee1

Please sign in to comment.