mirror of
https://github.com/logos-storage/logtools.git
synced 2026-01-02 13:33:07 +00:00
allow escaped quotes in topic values
This commit is contained in:
parent
0a18c3c092
commit
aa1bd2e161
@ -14,9 +14,9 @@ _LOG_LINE = re.compile(
|
|||||||
r'count=(?P<count>\d+)$'
|
r'count=(?P<count>\d+)$'
|
||||||
)
|
)
|
||||||
|
|
||||||
_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("[^"]+"|\S+)$')
|
_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("([^"\\]|\\")+"|\S+)$')
|
||||||
|
|
||||||
_TOPICS_KV = re.compile(r'(?P<key>\w+)=(?P<value>"[^"]+"|\S+)')
|
_TOPICS_KV = re.compile(r'(?P<key>\w+)=(?P<value>"(?:[^"\\]|\\")+"|\S+)')
|
||||||
|
|
||||||
|
|
||||||
class LogLevel(Enum):
|
class LogLevel(Enum):
|
||||||
|
|||||||
@ -52,7 +52,7 @@ def test_should_parse_chronicles_fields():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_should_parse_topics_with_non_alphanumeric_characters():
|
def test_should_parse_topics_with_non_alphanumeric_character_values():
|
||||||
source = ChroniclesRawSource(
|
source = ChroniclesRawSource(
|
||||||
StringLogSource(
|
StringLogSource(
|
||||||
lines='WRN 2024-02-02 20:38:47.316+00:00 a message topics="codex pendingblocks" address="cid: zDx*QP4zx9" '
|
lines='WRN 2024-02-02 20:38:47.316+00:00 a message topics="codex pendingblocks" address="cid: zDx*QP4zx9" '
|
||||||
@ -68,3 +68,21 @@ def test_should_parse_topics_with_non_alphanumeric_characters():
|
|||||||
'topics': '"codex pendingblocks"',
|
'topics': '"codex pendingblocks"',
|
||||||
'address': '"cid: zDx*QP4zx9"',
|
'address': '"cid: zDx*QP4zx9"',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_parse_topics_with_escaped_quotes_in_values():
|
||||||
|
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\\""',
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "logtools"
|
name = "logtools"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["gmega <giuliano@status.im>"]
|
authors = ["gmega <giuliano@status.im>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user