Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ def _format_time_rfc3339(timestamp, datefmt):


def _xfmt(val):
if isinstance(val, str):
return val
def _dofmt(v):
if isinstance(v, str):
return v
else:
return jsonext.dumps(v)

# NOTE: This is for compatibility with older formatting
if isinstance(val, (list, tuple, set)):
return ','.join(val)
return ','.join(_dofmt(v) for v in val)

return jsonext.dumps(val)
return _dofmt(val)


class CheckFieldFormatter(logging.Formatter):
Expand Down
5 changes: 3 additions & 2 deletions unittests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def error():
'fakejob')
test.job._completion_time = time.time()
test.custom = 'hello extras'
test.custom_list = ['custom', 'attr']
test.custom_list = ['custom', 3.0, ['hello', 'world']]
test.custom_dict = {'a': 1, 'b': 2}
test.deferred = sn.defer('hello')
test.deferred_error = error()
Expand Down Expand Up @@ -163,7 +163,8 @@ def test_logger_dynamic_attributes(logfile, logger_with_check):
logger_with_check.logger.handlers[0].setFormatter(formatter)
logger_with_check.info('xxx')
assert _pattern_in_logfile(
r'hello extras\|custom,attr\|null\|{"a": 1, "b": 2}', logfile
r'hello extras\|custom,3.0,\["hello", "world"\]\|null\|'
r'{"a": 1, "b": 2}', logfile
)


Expand Down