Database & Migrations: - Add application_logs table migration for hybrid cloud logging - Add companies table migration and restructure vendor relationships Logging System: - Implement hybrid logging system (database + file) - Add log_service for centralized log management - Create admin logs page with filtering and viewing capabilities - Add init_log_settings.py script for log configuration - Enhance core logging with database integration Marketplace Integration: - Add marketplace admin page with product management - Create marketplace vendor page with product listings - Implement marketplace.js for both admin and vendor interfaces - Add marketplace integration documentation Admin Enhancements: - Add imports management page and functionality - Create settings page for admin configuration - Add vendor themes management page - Enhance vendor detail and edit pages - Improve code quality dashboard and violation details - Add logs viewing and management - Update icons guide and shared icon system Architecture & Documentation: - Document frontend structure and component architecture - Document models structure and relationships - Add vendor-in-token architecture documentation - Add vendor RBAC (role-based access control) documentation - Document marketplace integration patterns - Update architecture patterns documentation Infrastructure: - Add platform static files structure (css, img, js) - Move architecture_scan.py to proper models location - Update model imports and registrations - Enhance exception handling - Update dependency injection patterns UI/UX: - Improve vendor edit interface - Update admin user interface - Enhance page templates documentation - Add vendor marketplace interface
118 lines
3.7 KiB
Python
118 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Initialize default log settings in database.
|
|
|
|
Run this script to create default logging configuration settings.
|
|
"""
|
|
|
|
# Import all models to avoid SQLAlchemy relationship issues
|
|
import models # noqa: F401
|
|
from app.core.database import SessionLocal
|
|
from models.database.admin import AdminSetting
|
|
|
|
|
|
def init_log_settings():
|
|
"""Create default log settings if they don't exist."""
|
|
db = SessionLocal()
|
|
|
|
try:
|
|
settings_to_create = [
|
|
{
|
|
"key": "log_level",
|
|
"value": "INFO",
|
|
"value_type": "string",
|
|
"category": "logging",
|
|
"description": "Application log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
|
"is_public": False,
|
|
"is_encrypted": False,
|
|
},
|
|
{
|
|
"key": "log_file_max_size_mb",
|
|
"value": "10",
|
|
"value_type": "integer",
|
|
"category": "logging",
|
|
"description": "Maximum log file size in MB before rotation",
|
|
"is_public": False,
|
|
"is_encrypted": False,
|
|
},
|
|
{
|
|
"key": "log_file_backup_count",
|
|
"value": "5",
|
|
"value_type": "integer",
|
|
"category": "logging",
|
|
"description": "Number of rotated log files to keep",
|
|
"is_public": False,
|
|
"is_encrypted": False,
|
|
},
|
|
{
|
|
"key": "db_log_retention_days",
|
|
"value": "30",
|
|
"value_type": "integer",
|
|
"category": "logging",
|
|
"description": "Number of days to retain logs in database",
|
|
"is_public": False,
|
|
"is_encrypted": False,
|
|
},
|
|
{
|
|
"key": "file_logging_enabled",
|
|
"value": "true",
|
|
"value_type": "boolean",
|
|
"category": "logging",
|
|
"description": "Enable file-based logging",
|
|
"is_public": False,
|
|
"is_encrypted": False,
|
|
},
|
|
{
|
|
"key": "db_logging_enabled",
|
|
"value": "true",
|
|
"value_type": "boolean",
|
|
"category": "logging",
|
|
"description": "Enable database logging for critical events",
|
|
"is_public": False,
|
|
"is_encrypted": False,
|
|
},
|
|
]
|
|
|
|
created_count = 0
|
|
updated_count = 0
|
|
|
|
for setting_data in settings_to_create:
|
|
existing = (
|
|
db.query(AdminSetting)
|
|
.filter(AdminSetting.key == setting_data["key"])
|
|
.first()
|
|
)
|
|
|
|
if existing:
|
|
print(f"✓ Setting '{setting_data['key']}' already exists (value: {existing.value})")
|
|
updated_count += 1
|
|
else:
|
|
setting = AdminSetting(**setting_data)
|
|
db.add(setting)
|
|
created_count += 1
|
|
print(f"✓ Created setting '{setting_data['key']}' = {setting_data['value']}")
|
|
|
|
db.commit()
|
|
|
|
print("\n" + "=" * 70)
|
|
print("LOG SETTINGS INITIALIZATION COMPLETE")
|
|
print("=" * 70)
|
|
print(f" Created: {created_count} settings")
|
|
print(f" Existing: {updated_count} settings")
|
|
print(f" Total: {len(settings_to_create)} settings")
|
|
print("=" * 70)
|
|
|
|
except Exception as e:
|
|
db.rollback()
|
|
print(f"Error initializing log settings: {e}")
|
|
raise
|
|
finally:
|
|
db.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("=" * 70)
|
|
print("INITIALIZING LOG SETTINGS")
|
|
print("=" * 70)
|
|
init_log_settings()
|