feat: add structured JSON logging for all feature usage (Phase 2)
- Create feature_logger.py with JSON logging infrastructure - Add log_feature_usage() calls to all 9 routers after check_feature_access() - Logs written to /app/logs/feature-usage.log - Tracks all usage (not just violations) for future analysis - Phase 2: Non-blocking monitoring complete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ddcd2f4350
commit
1298bd235f
10 files changed
+115
-1
No files matched your search
@@ -19,6 +19,7 @@ from fastapi import APIRouter, HTTPException, UploadFile, File, Header, Depends
|
||||
from db import get_db, get_cursor
|
||||
from auth import require_auth, check_feature_access, increment_feature_usage
|
||||
from routers.profiles import get_pid
|
||||
from feature_logger import log_feature_usage
|
||||
|
||||
router = APIRouter(prefix="/api/import", tags=["import"])
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -45,6 +46,8 @@ async def import_zip(
|
||||
|
||||
# Phase 2: Check feature access (non-blocking, log only)
|
||||
access = check_feature_access(pid, 'data_import')
|
||||
log_feature_usage(pid, 'data_import', access, 'import_zip')
|
||||
|
||||
if not access['allowed']:
|
||||
logger.warning(
|
||||
f"[FEATURE-LIMIT] User {pid} would be blocked: "
|
||||
|
||||
Reference in new issue
Block a user