Skip to content

Repository files navigation

SessionLedger

Session tracking, simplified. A command-line tool that reads user login/logout event logs and reports who was on which machine, when, and for how long.

Features

  • Full session history and a live "who's online right now" view
  • Filter sessions by user or by date
  • Export reports to CSV or JSON
  • Handles messy real-world logs without crashing -- duplicate logins, orphan logouts, unclosed sessions, malformed lines, and unsorted files are all detected and handled gracefully
  • Usernames are case-insensitive
  • Styled terminal output with a cyan-to-green gradient banner (rich + pyfiglet)

Screenshots

Help screen Help screen

Full session report Full report

Live view (currently active sessions) Live view

Architecture

SessionLedger uses a strict layered architecture -- the business logic has zero knowledge of files, the terminal, or argparse:

Log file --> EventParser --> SessionTracker --> Reporter --> CLI (rich output) (I/O only)(pure logic,(formatting zero I/O)only)

This separation is what makes the core logic reusable at any scale. SessionTracker doesn't know or care whether events came from a static log file, a live feed, or a message queue like Kafka across 1,000s of machines -- only the I/O layer feeding it would change, not the tracking logic itself.

Installation

git clone https://github.com/Aayush29052006/Session-Ledger.git
cd Session-Ledger
python -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate
pip install -r requirements.txt

Usage

Show the help screen:

python -m sessionledger.cli --help

Full session history:

python -m sessionledger.cli --log sample_logs/sample_events.csv

Only currently active sessions:

python -m sessionledger.cli --log sample_logs/sample_events.csv --live

Filter by user:

python -m sessionledger.cli --log sample_logs/sample_events.csv --user alice

Filter by date:

python -m sessionledger.cli --log sample_logs/sample_events.csv --date 2026-07-14

Export to CSV or JSON:

python -m sessionledger.cli --log sample_logs/sample_events.csv --export csv
python -m sessionledger.cli --log sample_logs/sample_events.csv --export json

Log File Format

Plain CSV, one event per line, no header row:

timestamp,machine,user,event_type 2026-07-14 08:03:12,server1,alice,login 2026-07-14 08:41:07,server1,alice,logout

Edge Cases Handled

Case Behavior
Duplicate login Warning logged, first login time kept
Orphan logout (no matching login) Warning logged, event skipped
Session with no logout Marked as "active"
Malformed / corrupted line Warning logged, line skipped
Unknown event type Warning logged, line skipped
Unsorted log file Automatically sorted by timestamp before processing
Empty log file "No sessions found" message, no crash
Case differences in usernames Treated as the same user

Full test matrix in tests/TEST_PLAN.md.

Running Tests

python -m pytest -v

27 tests covering the parser, tracker, and reporter layers.

Tech Stack

  • Python 3
  • rich -- styled terminal output
  • pyfiglet -- ASCII art banner
  • pytest -- testing

Project Status

Built as a portfolio project following a structured 14-step development process: problem definition, architecture design, edge-case planning, bottom-up implementation with tests alongside every feature, and documentation.

Author

Aayush Jivan Chaudhari

About

CLI tool that parses login/logout event logs and reports session history, currently active users, and exportable reports (CSV/JSON). Built with Python, rich, and pyfiglet.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages