Fix debug mode: preserve debug when called from option 6
This commit is contained in:
1 parent
16bdb2d778
commit
23a7392bcd
2 files changed
+50
-17
No files matched your search
+15
-15
@@ -135,18 +135,18 @@ def create_app(settings_path=None):
|
||||
|
||||
if debug_mode:
|
||||
# Comprehensive debug logging for every request (all sanitized)
|
||||
logger.debug("=" * 60)
|
||||
logger.debug(f"REQUEST: {request.method} {request.path}")
|
||||
logger.debug(f" User: {sanitize_for_log(user)}")
|
||||
logger.debug(f" IP: {request.remote_addr}")
|
||||
logger.debug(f" UA: {sanitize_for_log(request.headers.get('User-Agent', 'Unknown')[:80])}")
|
||||
logger.debug(f" Referer: {sanitize_for_log(request.headers.get('Referer', 'None'))}")
|
||||
logger.debug(f" Args: {sanitize_for_log(request.args.to_dict())}")
|
||||
logging.getLogger().debug("=" * 60)
|
||||
logging.getLogger().debug(f"REQUEST: {request.method} {request.path}")
|
||||
logging.getLogger().debug(f" User: {sanitize_for_log(user)}")
|
||||
logging.getLogger().debug(f" IP: {request.remote_addr}")
|
||||
logging.getLogger().debug(f" UA: {sanitize_for_log(request.headers.get('User-Agent', 'Unknown')[:80])}")
|
||||
logging.getLogger().debug(f" Referer: {sanitize_for_log(request.headers.get('Referer', 'None'))}")
|
||||
logging.getLogger().debug(f" Args: {sanitize_for_log(request.args.to_dict())}")
|
||||
if request.is_json:
|
||||
logger.debug(f" JSON Body: {sanitize_for_log(request.get_json(silent=True) or {})}")
|
||||
logging.getLogger().debug(f" JSON Body: {sanitize_for_log(request.get_json(silent=True) or {})}")
|
||||
elif request.form:
|
||||
logger.debug(f" Form: {sanitize_for_log(request.form.to_dict())}")
|
||||
logger.debug(f" Session: {sanitize_for_log(list(session.keys()) if session else 'None')}")
|
||||
logging.getLogger().debug(f" Form: {sanitize_for_log(request.form.to_dict())}")
|
||||
logging.getLogger().debug(f" Session: {sanitize_for_log(list(session.keys()) if session else 'None')}")
|
||||
log_request_details(logging.getLogger(), request)
|
||||
else:
|
||||
logging.debug(f"Request: {request.method} {request.path} from {user}")
|
||||
@@ -162,12 +162,12 @@ def create_app(settings_path=None):
|
||||
|
||||
if debug_mode:
|
||||
# Comprehensive debug logging for every response
|
||||
logger.debug(f"RESPONSE: {request.method} {request.path} -> {response.status_code}")
|
||||
logger.debug(f" Duration: {duration*1000:.1f}ms")
|
||||
logger.debug(f" Content-Type: {response.content_type}")
|
||||
logger.debug(f" Content-Length: {response.content_length}")
|
||||
logging.getLogger().debug(f"RESPONSE: {request.method} {request.path} -> {response.status_code}")
|
||||
logging.getLogger().debug(f" Duration: {duration*1000:.1f}ms")
|
||||
logging.getLogger().debug(f" Content-Type: {response.content_type}")
|
||||
logging.getLogger().debug(f" Content-Length: {response.content_length}")
|
||||
log_response_details(logging.getLogger(), response, duration * 1000)
|
||||
logger.debug("=" * 60)
|
||||
logging.getLogger().debug("=" * 60)
|
||||
else:
|
||||
# Only log API requests to avoid noise
|
||||
if request.path.startswith('/api') or request.path.startswith('/server'):
|
||||
|
||||
+35
-2
@@ -1735,6 +1735,10 @@ logging:
|
||||
}
|
||||
|
||||
function Start-Dashboard {
|
||||
param(
|
||||
[switch]$PreserveDebug
|
||||
)
|
||||
|
||||
Write-Host ""
|
||||
Write-Host " Starting dashboard..." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
@@ -1777,6 +1781,22 @@ print(json.dumps(s))
|
||||
}
|
||||
$settings = $settingsJson | ConvertFrom-Json
|
||||
|
||||
# Ensure debug logging is disabled for normal start (unless PreserveDebug is set)
|
||||
if (-not $PreserveDebug) {
|
||||
$needsSave = $false
|
||||
if ($settings.logging) {
|
||||
if ($settings.logging.debug_enabled -eq $true) {
|
||||
$settings.logging.debug_enabled = $false
|
||||
$settings.logging.level = "INFO"
|
||||
$needsSave = $true
|
||||
}
|
||||
}
|
||||
if ($needsSave) {
|
||||
$settingsJson = $settings | ConvertTo-Json -Depth 10
|
||||
$settingsJson | python "$env:TEMP\update_settings_debug.py" $settingsFile 2>$null
|
||||
}
|
||||
}
|
||||
|
||||
$ServerHost = $settings.server.host
|
||||
$SSHUser = $settings.server.user
|
||||
$LocalPort = [int]$settings.database.port
|
||||
@@ -2172,6 +2192,19 @@ function Start-DashboardDebug {
|
||||
Write-Host " Starting Dashboard with DEBUG LOGGING enabled" -ForegroundColor Magenta
|
||||
Write-Host " ============================================================" -ForegroundColor Magenta
|
||||
Write-Host ""
|
||||
Write-Host " ⚠️ WARNING: Debug logging can significantly impact performance!" -ForegroundColor Yellow
|
||||
Write-Host " - Logs every HTTP request/response with full headers" -ForegroundColor Yellow
|
||||
Write-Host " - Logs all SSH commands and results" -ForegroundColor Yellow
|
||||
Write-Host " - Logs all database queries" -ForegroundColor Yellow
|
||||
Write-Host " - Logs all Kubernetes operations" -ForegroundColor Yellow
|
||||
Write-Host " - Only use this when troubleshooting, not for regular use" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
$continue = Read-Host " Continue with debug mode? (y/N)"
|
||||
if ($continue -ne 'y' -and $continue -ne 'Y') {
|
||||
Write-Host " Cancelled." -ForegroundColor Cyan
|
||||
return
|
||||
}
|
||||
|
||||
# Check Python
|
||||
if (-not (Test-Python)) {
|
||||
@@ -2250,8 +2283,8 @@ print('ok')
|
||||
Write-Host " Continuing with dashboard startup..." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
# Now start the dashboard (reuses all the same logic)
|
||||
Start-Dashboard
|
||||
# Now start the dashboard (reuses all the same logic but preserve debug)
|
||||
Start-Dashboard -PreserveDebug
|
||||
}
|
||||
|
||||
# ── Main Loop ───────────────────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user