Skip to content

# Issue #25 — Add structured JSONL logger for track lifecycle events #31

@Devnil434

Description

@Devnil434

Description

Currently lifecycle events (BORN, LOST, DEAD) are only printed to the console.

Add a structured JSONL logger that appends lifecycle events into:

data/logs/tracks.jsonl

Each event should be stored as one JSON object per line so events can later
be replayed, inspected, or analyzed offline.


Example Output

{"event":"BORN","track_id":3,"frame_id":0,"zones":["restricted_door"],"timestamp_ms":1718000000000}
{"event":"DEAD","track_id":3,"frame_id":900,"dwell_time_seconds":30.1,"timestamp_ms":1718000030000}

Files to Touch

libs/utils/lifecycle_logger.py
services/tracking/tracker.py
tests/test_lifecycle_logger.py

Implementation Notes

  • Create reusable helper:

    lifecycle_logger.log(event)
  • Call logger inside _emit_lifecycle()

  • Logger should append safely without overwriting previous events

  • Support configurable path via:

    LIFECYCLE_LOG_PATH

Acceptance Criteria

  • JSONL file created automatically
  • Events appended correctly
  • Path configurable through env variable
  • Unit tests mock file writes (no real disk I/O)
  • Existing tests remain green

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions