parse timezone offsets in space-separated log timestamps - #32
Conversation
Reviewer's GuideThis PR extends timestamp parsing to handle timezone offsets in space-separated log timestamps (including fractional seconds) and updates CLI time filtering logic to correctly compare aware and naive timestamps, with new tests covering these behaviors. Sequence diagram for CLI timestamp parsing and timezone alignmentsequenceDiagram
actor User
participant CLI
participant parse_timestamp
User->>CLI: run with start_time, end_time
CLI->>CLI: read log line
CLI->>parse_timestamp: parse_timestamp(line)
parse_timestamp-->>CLI: timestamp
alt timestamp is not None and timestamp.tzinfo is not None
opt start_time is not None and start_time.tzinfo is None
CLI->>CLI: start_time.replace(tzinfo=timestamp.tzinfo)
end
opt end_time is not None and end_time.tzinfo is None
CLI->>CLI: end_time.replace(tzinfo=timestamp.tzinfo)
end
else timestamp is not None and timestamp.tzinfo is None
opt start_time is not None and start_time.tzinfo is not None
CLI->>CLI: timestamp.replace(tzinfo=start_time.tzinfo)
end
opt end_time is not None and end_time.tzinfo is not None
CLI->>CLI: timestamp.replace(tzinfo=end_time.tzinfo)
end
end
alt start_time is not None and (timestamp is None or timestamp < start_time)
CLI->>CLI: skip line (before start_time)
else end_time is not None and (timestamp is None or timestamp > end_time)
CLI->>CLI: skip line (after end_time)
else
CLI->>CLI: parse and analyze line
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What does this change do?
Parse timezone offsets when log timestamps use a space between the date and time, including fractional seconds. The CLI now aligns aware and naive timestamps before applying time filters.
Why is this needed?
The timestamp matcher accepted these offsets, but the parser did not, and the CLI could compare an aware log timestamp with a naive filter boundary.
Testing
PYTHONPATH=src pytest -q tests/test_utils.py tests/test_parsers.py tests/test_analyzer.py tests/test_cli.py50 passed.
Drafted with Zo Bot; reviewed by the repository owner.
Summary by Sourcery
Support timezone-aware and mixed-awareness timestamp handling in CLI time filtering and extend timestamp parsing for additional log formats.
New Features:
Bug Fixes:
Tests: