Skip to content

add-auditing-system #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

add-auditing-system #224

wants to merge 4 commits into from

Conversation

hu55ain3laa
Copy link

@hu55ain3laa hu55ain3laa commented May 8, 2025

Description

a complete auditing and logging system for FastCRUD that tracks database operations, user actions, and data changes. The new audit module provides tools to enhance accountability, compliance, and debugging capabilities without requiring significant changes to existing code.

Changes

  • Operation Tracking: Records create, read, update, and delete operations
  • Change Tracking: Captures before/after values for all field updates
  • User Attribution: Tracks which user performed each operation
  • Context Capture: Records IP address, user agent, and custom context data
  • Integrated Logging: Works with both database storage and standard Python logging
  • Non-intrusive Implementation: Drop-in replacement via AuditableFastCRUD class

Implementation Details

The auditing system consists of the following components:

  1. Database Models: AuditLog and AuditLogEntry tables for storing audit data
  2. Audit Logger: Core logging functionality with both async and sync support
  3. Context Management: Session-based context tracking for user information
  4. Auditable CRUD Class: Extension of FastCRUD with built-in auditing capabilities

Tests

  • ✅ Added comprehensive tests in tests/sqlalchemy/audit/ directory
  • ✅ Code passes mypy type checking
  • ✅ Code follows style guidelines (verified with ruff)
  • ✅ Documentation added for all components

Checklist

  • ✅ I have read the CONTRIBUTING document.
  • ✅ My code follows the code style of this project.
  • ✅ I have added necessary documentation (if appropriate).
  • ✅ I have added tests that cover my changes (if applicable).
  • ✅ All new and existing tests passed.

a complete auditing and logging system for FastCRUD that tracks database operations, user actions, and data changes. The new `audit` module provides tools to enhance accountability, compliance, and debugging capabilities without requiring significant changes to existing code.
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.

1 participant