feat: Add detailed IndieAuth logging with security-aware token redaction
- Add logging helper functions with automatic token redaction - Implement comprehensive logging throughout auth flow - Add production warning for DEBUG logging - Add 14 new tests for logging functionality - Update version to v0.7.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,54 @@ StarPunk package initialization
|
||||
Creates and configures the Flask application
|
||||
"""
|
||||
|
||||
import logging
|
||||
from flask import Flask
|
||||
|
||||
|
||||
def configure_logging(app):
|
||||
"""
|
||||
Configure application logging based on LOG_LEVEL
|
||||
|
||||
Args:
|
||||
app: Flask application instance
|
||||
"""
|
||||
log_level = app.config.get("LOG_LEVEL", "INFO").upper()
|
||||
|
||||
# Set Flask logger level
|
||||
app.logger.setLevel(getattr(logging, log_level, logging.INFO))
|
||||
|
||||
# Configure handler with detailed format for DEBUG
|
||||
handler = logging.StreamHandler()
|
||||
|
||||
if log_level == "DEBUG":
|
||||
formatter = logging.Formatter(
|
||||
"[%(asctime)s] %(levelname)s - %(name)s: %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
|
||||
# Warn if DEBUG enabled in production
|
||||
if not app.debug and app.config.get("ENV") != "development":
|
||||
app.logger.warning(
|
||||
"=" * 70
|
||||
+ "\n"
|
||||
+ "WARNING: DEBUG logging enabled in production!\n"
|
||||
+ "This logs detailed HTTP requests/responses.\n"
|
||||
+ "Sensitive data is redacted, but consider using INFO level.\n"
|
||||
+ "Set LOG_LEVEL=INFO in production for normal operation.\n"
|
||||
+ "=" * 70
|
||||
)
|
||||
else:
|
||||
formatter = logging.Formatter(
|
||||
"[%(asctime)s] %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
# Remove existing handlers and add our configured handler
|
||||
app.logger.handlers.clear()
|
||||
app.logger.addHandler(handler)
|
||||
|
||||
|
||||
def create_app(config=None):
|
||||
"""
|
||||
Application factory for StarPunk
|
||||
@@ -23,6 +68,9 @@ def create_app(config=None):
|
||||
|
||||
load_config(app, config)
|
||||
|
||||
# Configure logging
|
||||
configure_logging(app)
|
||||
|
||||
# Initialize database
|
||||
from starpunk.database import init_db
|
||||
|
||||
@@ -105,5 +153,5 @@ def create_app(config=None):
|
||||
|
||||
# Package version (Semantic Versioning 2.0.0)
|
||||
# See docs/standards/versioning-strategy.md for details
|
||||
__version__ = "0.6.2"
|
||||
__version_info__ = (0, 6, 2)
|
||||
__version__ = "0.7.0"
|
||||
__version_info__ = (0, 7, 0)
|
||||
|
||||
Reference in New Issue
Block a user