Skip to content

Implement user activity logging for all user interactions#2

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-1
Draft

Implement user activity logging for all user interactions#2
Copilot wants to merge 2 commits intomainfrom
copilot/fix-1

Conversation

Copy link
Copy Markdown

Copilot AI commented Sep 23, 2025

This PR implements comprehensive user activity logging to satisfy the business requirement: "User activity shall be logged." The solution captures all user interactions and saves them to structured log files for analysis by log management systems.

Changes Made

New Logging System

  • user_activity_logger.py: Complete logging utility with JSON-structured output, Flask integration for IP/User-Agent capture, and configurable log files
  • tests/test_user_activity_logger.py: Comprehensive unit tests covering all logging scenarios
  • LOGGING_README.md: Documentation for setup, configuration, and log management system integration

Updated Application

Modified wine.py to integrate logging at all user interaction points:

  • Login attempts (successful and failed with failure reasons)
  • User logout events
  • Registration attempts with validation failure details
  • Wine classification requests with complete input data and predictions
  • Profile page access events
  • Password change attempts with success/failure tracking
  • Contact form submissions

Sample Log Output

{"timestamp": "2024-01-15T10:30:45.123456", "action": "login_attempt", "user_id": 123, "username": "johndoe", "ip_address": "192.168.1.100", "user_agent": "Mozilla/5.0...", "details": {"success": true, "attempted_username": "johndoe"}}

{"timestamp": "2024-01-15T10:35:12.789012", "action": "wine_classification", "user_id": 123, "username": "johndoe", "ip_address": "192.168.1.100", "user_agent": "Mozilla/5.0...", "details": {"wine_characteristics": {"alcohol": 12.5, "malic_acid": 2.3, ...}, "prediction": 1}}

Key Features

  • Structured JSON format for easy parsing by log management systems (ELK Stack, Splunk, etc.)
  • Comprehensive coverage of all user interactions as required
  • Security-conscious design that avoids logging sensitive data like passwords
  • Minimal code changes with surgical integration into existing application
  • Analysis-ready logs with timestamps, user identification, IP addresses, and contextual details

The implementation ensures user actions are properly logged for audit trails and analysis while maintaining security best practices.

Fixes #1.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Copy Markdown
Author

Copilot AI commented Sep 23, 2025

@jefferyepayne 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: jefferyepayne <50836441+jefferyepayne@users.noreply.github.com>
Copilot AI changed the title [WIP] Create log capability for user interactions Implement user activity logging for all user interactions Sep 23, 2025
Copilot AI requested a review from jefferyepayne September 23, 2025 23:16
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