mirror of
https://github.com/logos-storage/logtools.git
synced 2026-01-08 16:33:13 +00:00
fix field parse regex
This commit is contained in:
parent
0a34c82360
commit
6e0e3a0485
@ -14,9 +14,9 @@ _LOG_LINE = re.compile(
|
|||||||
r'count=(?P<count>\d+)$'
|
r'count=(?P<count>\d+)$'
|
||||||
)
|
)
|
||||||
|
|
||||||
_TOPICS = re.compile(r'((\w+=("[\w\s]+"|\S+) )+)?\w+=("[\w\s]+"|\S+)$')
|
_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("[^"]+"|\S+)$')
|
||||||
|
|
||||||
_TOPICS_KV = re.compile(r'(?P<key>\w+)=(?P<value>"[\w\s]+"|\S+)')
|
_TOPICS_KV = re.compile(r'(?P<key>\w+)=(?P<value>"[^"]+"|\S+)')
|
||||||
|
|
||||||
|
|
||||||
class LogLevel(Enum):
|
class LogLevel(Enum):
|
||||||
|
|||||||
@ -50,3 +50,21 @@ def test_should_parse_chronicles_fields():
|
|||||||
'type': 'WantBlock',
|
'type': 'WantBlock',
|
||||||
'items': '1',
|
'items': '1',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_parse_topics_with_non_alphanumeric_characters():
|
||||||
|
source = ChroniclesRawSource(
|
||||||
|
StringLogSource(
|
||||||
|
lines='WRN 2024-02-02 20:38:47.316+00:00 a message topics="codex pendingblocks" address="cid: zDx*QP4zx9" '
|
||||||
|
'count=10641'
|
||||||
|
)
|
||||||
|
).__iter__()
|
||||||
|
|
||||||
|
line = next(source)
|
||||||
|
|
||||||
|
assert line.message == "a message"
|
||||||
|
assert line.count == 10641
|
||||||
|
assert line.fields == {
|
||||||
|
'topics': '"codex pendingblocks"',
|
||||||
|
'address': '"cid: zDx*QP4zx9"',
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user