Files
digiserver/app/utils/logger.py
ske087 1eb0aa3658 feat: v1.1.0 - Production-Ready Docker Deployment
🚀 Major Release: DigiServer v1.1.0 Production Deployment

## 📁 Project Restructure
- Moved all application code to app/ directory for Docker containerization
- Centralized persistent data in data/ directory with volume mounting
- Removed development artifacts and cleaned up project structure

## 🐳 Docker Integration
- Added production-ready Dockerfile with LibreOffice and poppler-utils
- Updated docker-compose.yml for production deployment
- Added .dockerignore for optimized build context
- Created automated deployment script (deploy-docker.sh)
- Added cleanup script (cleanup-docker.sh)

## 📄 Document Processing Enhancements
- Integrated LibreOffice for professional PPTX to PDF conversion
- Implemented PPTX → PDF → 4K JPG workflow for optimal quality
- Added poppler-utils for enhanced PDF processing
- Simplified PDF conversion to 300 DPI for reliability

## 🔧 File Management Improvements
- Fixed absolute path resolution for containerized deployment
- Updated all file deletion functions with proper path handling
- Enhanced bulk delete functions for players and groups
- Improved file upload workflow with consistent path management

## 🛠️ Code Quality & Stability
- Cleaned up pptx_converter.py from 442 to 86 lines
- Removed all Python cache files (__pycache__/, *.pyc)
- Updated file operations for production reliability
- Enhanced error handling and logging

## 📚 Documentation Updates
- Updated README.md with Docker deployment instructions
- Added comprehensive DEPLOYMENT.md guide
- Included production deployment best practices
- Added automated deployment workflow documentation

## 🔐 Security & Production Features
- Environment-based configuration
- Health checks and container monitoring
- Automated admin user creation
- Volume-mounted persistent data
- Production logging and error handling

##  Ready for Production
- Clean project structure optimized for Docker
- Automated deployment with ./deploy-docker.sh
- Professional document processing pipeline
- Reliable file management system
- Complete documentation and deployment guides

Access: http://localhost:8880 | Admin: admin/Initial01!
2025-08-05 18:04:02 -04:00

84 lines
3.0 KiB
Python

import datetime
from extensions import db
from models import ServerLog
def log_action(action):
"""
Log an action to the server log database
"""
try:
new_log = ServerLog(action=action)
db.session.add(new_log)
db.session.commit()
print(f"Logged action: {action}")
except Exception as e:
print(f"Error logging action: {e}")
db.session.rollback()
def get_recent_logs(limit=20):
"""
Get the most recent log entries
"""
return ServerLog.query.order_by(ServerLog.timestamp.desc()).limit(limit).all()
# Helper functions for common log actions
def log_upload(file_type, file_name, target_type, target_name):
log_action(f"{file_type.upper()} file '{file_name}' uploaded for {target_type} '{target_name}'")
def log_process(file_type, file_name, target_type, target_name):
log_action(f"{file_type.upper()} file '{file_name}' processed for {target_type} '{target_name}'")
def log_player_created(username, hostname):
log_action(f"Player '{username}' with hostname '{hostname}' was created")
def log_player_edited(username):
log_action(f"Player '{username}' was edited")
def log_player_deleted(username):
log_action(f"Player '{username}' was deleted")
def log_group_created(name):
log_action(f"Group '{name}' was created")
def log_group_edited(name):
log_action(f"Group '{name}' was edited")
def log_group_deleted(name):
log_action(f"Group '{name}' was deleted")
def log_user_created(username, role):
log_action(f"User '{username}' with role '{role}' was created")
def log_user_role_changed(username, new_role):
log_action(f"User '{username}' role changed to '{new_role}'")
def log_user_deleted(username):
log_action(f"User '{username}' was deleted")
def log_content_deleted(content_name, target_type, target_name):
log_action(f"Content '{content_name}' removed from {target_type} '{target_name}'")
def log_settings_changed(setting_name):
log_action(f"Setting '{setting_name}' was changed")
def log_files_cleaned(count):
log_action(f"{count} unused files were cleaned from storage")
# New logging functions for more detailed activities
def log_player_added_to_group(player_name, group_name):
log_action(f"Player '{player_name}' was added to group '{group_name}'")
def log_player_removed_from_group(player_name, group_name):
log_action(f"Player '{player_name}' was removed from group '{group_name}'")
def log_player_unlocked(player_name):
log_action(f"Player '{player_name}' was unlocked from its group")
def log_content_reordered(target_type, target_name):
log_action(f"Content for {target_type} '{target_name}' was reordered")
def log_content_duration_changed(content_name, old_duration, new_duration, target_type, target_name):
log_action(f"Duration for '{content_name}' changed from {old_duration}s to {new_duration}s in {target_type} '{target_name}'")
def log_content_added(content_name, target_type, target_name):
log_action(f"Content '{content_name}' added to {target_type} '{target_name}'")