Skip to content

Refactor parse_logger to handle structured logger records with error …#33

Merged
JasonBrave merged 5 commits intomainfrom
j7zang/parsley-logger
Jul 27, 2025
Merged

Refactor parse_logger to handle structured logger records with error …#33
JasonBrave merged 5 commits intomainfrom
j7zang/parsley-logger

Conversation

@zangjiucheng
Copy link
Member

@zangjiucheng zangjiucheng commented May 25, 2025

This pull request includes a significant rewrite of the parse_logger function in parsley/parsley.py to improve its robustness, readability, and adherence to the expected logger record format. The new implementation introduces structured parsing with validation and error handling.

Changes to parse_logger function:

  • Improved Input Handling:

    • Changed the input type from str to bytes to align with the binary format of logger records.
  • Logger Record Parsing:

    • Added a detailed docstring explaining the binary layout of the logger record, including the structure of the header and payload.
    • Introduced the use of the struct module for parsing the header (SID, timestamp, and DLC) in a structured and endian-aware manner.
  • Validation and Error Handling:

    • Implemented validations for logger record structure, including checks for the "LOG" signature, header completeness, SID constraints, DLC range, and payload length. Raises ValueError for any structural issues.
  • Logging for Debugging:

    • Added a print statement to log parsed values (page_number, SID, timestamp, DLC, and data) for debugging purposes.…handling

This change is Reviewable

@zangjiucheng zangjiucheng force-pushed the j7zang/parsley-logger branch from a5c4195 to f71a414 Compare May 28, 2025 04:27
@zangjiucheng zangjiucheng marked this pull request as ready for review May 28, 2025 16:57
@zangjiucheng zangjiucheng requested a review from JasonBrave May 28, 2025 16:58
@zangjiucheng zangjiucheng force-pushed the j7zang/parsley-logger branch from 77fe8d8 to c408273 Compare May 30, 2025 17:11
@zangjiucheng zangjiucheng force-pushed the j7zang/parsley-logger branch from c408273 to e04ddec Compare July 18, 2025 17:43
@JasonBrave JasonBrave force-pushed the j7zang/parsley-logger branch from e04ddec to 04b290f Compare July 27, 2025 23:23
Copy link
Member

@JasonBrave JasonBrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JasonBrave JasonBrave merged commit 3149a91 into main Jul 27, 2025
2 of 3 checks passed
@JasonBrave JasonBrave deleted the j7zang/parsley-logger branch July 27, 2025 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants