Coverage for /usr/local/lib/python3.10/site-packages/opal_common-0.0.0-py3.10.egg/opal_common/logging_utils/formatter.py: 64%

16 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 11:54 +0000

1class Formatter: 

2 MAX_FIELD_LEN = 25 

3 

4 def __init__(self, format_string: str): 

5 self.fmt = format_string 

6 

7 def limit_len(self, record, field, length=MAX_FIELD_LEN): 

8 # Shorten field content 

9 content = record[field] 

10 if len(content) > length: 10 ↛ 11line 10 didn't jump to line 11 because the condition on line 10 was never true

11 parts = content.split(".") 

12 if len(parts) > 2: 

13 content = f"{parts[0]}...{parts[-1]}" 

14 if len(content) > length: 14 ↛ 15line 14 didn't jump to line 15 because the condition on line 14 was never true

15 content = f"{content[:length-3]}..." 

16 record[field] = content 

17 

18 def format(self, record): 

19 self.limit_len(record, "name", 40) 

20 return self.fmt