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
@@ -16,6 +16,7 @@ import aiofiles
|
||||
from db import get_db, get_cursor, r2d
|
||||
from auth import require_auth, require_auth_flexible, check_feature_access, increment_feature_usage
|
||||
from routers.profiles import get_pid
|
||||
from feature_logger import log_feature_usage
|
||||
|
||||
router = APIRouter(prefix="/api/photos", tags=["photos"])
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -32,6 +33,8 @@ async def upload_photo(file: UploadFile=File(...), date: str="",
|
||||
|
||||
# Phase 2: Check feature access (non-blocking, log only)
|
||||
access = check_feature_access(pid, 'photos')
|
||||
log_feature_usage(pid, 'photos', access, 'upload')
|
||||
|
||||
if not access['allowed']:
|
||||
logger.warning(
|
||||
f"[FEATURE-LIMIT] User {pid} would be blocked: "
|
||||
|
||||
Reference in new issue
Block a user