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:
|
if debug_mode:
|
||||||
# Comprehensive debug logging for every request (all sanitized)
|
# Comprehensive debug logging for every request (all sanitized)
|
||||||
logger.debug("=" * 60)
|
logging.getLogger().debug("=" * 60)
|
||||||
logger.debug(f"REQUEST: {request.method} {request.path}")
|
logging.getLogger().debug(f"REQUEST: {request.method} {request.path}")
|
||||||
logger.debug(f" User: {sanitize_for_log(user)}")
|
logging.getLogger().debug(f" User: {sanitize_for_log(user)}")
|
||||||
logger.debug(f" IP: {request.remote_addr}")
|
logging.getLogger().debug(f" IP: {request.remote_addr}")
|
||||||
logger.debug(f" UA: {sanitize_for_log(request.headers.get('User-Agent', 'Unknown')[:80])}")
|
logging.getLogger().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'))}")
|
logging.getLogger().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(f" Args: {sanitize_for_log(request.args.to_dict())}")
|
||||||
if request.is_json:
|
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:
|
elif request.form:
|
||||||
logger.debug(f" Form: {sanitize_for_log(request.form.to_dict())}")
|
logging.getLogger().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" Session: {sanitize_for_log(list(session.keys()) if session else 'None')}")
|
||||||
log_request_details(logging.getLogger(), request)
|
log_request_details(logging.getLogger(), request)
|
||||||
else:
|
else:
|
||||||
logging.debug(f"Request: {request.method} {request.path} from {user}")
|
logging.debug(f"Request: {request.method} {request.path} from {user}")
|
||||||
@@ -162,12 +162,12 @@ def create_app(settings_path=None):
|
|||||||
|
|
||||||
if debug_mode:
|
if debug_mode:
|
||||||
# Comprehensive debug logging for every response
|
# Comprehensive debug logging for every response
|
||||||
logger.debug(f"RESPONSE: {request.method} {request.path} -> {response.status_code}")
|
logging.getLogger().debug(f"RESPONSE: {request.method} {request.path} -> {response.status_code}")
|
||||||
logger.debug(f" Duration: {duration*1000:.1f}ms")
|
logging.getLogger().debug(f" Duration: {duration*1000:.1f}ms")
|
||||||
logger.debug(f" Content-Type: {response.content_type}")
|
logging.getLogger().debug(f" Content-Type: {response.content_type}")
|
||||||
logger.debug(f" Content-Length: {response.content_length}")
|
logging.getLogger().debug(f" Content-Length: {response.content_length}")
|
||||||
log_response_details(logging.getLogger(), response, duration * 1000)
|
log_response_details(logging.getLogger(), response, duration * 1000)
|
||||||
logger.debug("=" * 60)
|
logging.getLogger().debug("=" * 60)
|
||||||
else:
|
else:
|
||||||
# Only log API requests to avoid noise
|
# Only log API requests to avoid noise
|
||||||
if request.path.startswith('/api') or request.path.startswith('/server'):
|
if request.path.startswith('/api') or request.path.startswith('/server'):
|
||||||
|
|||||||
+35
-2
@@ -1735,6 +1735,10 @@ logging:
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Start-Dashboard {
|
function Start-Dashboard {
|
||||||
|
param(
|
||||||
|
[switch]$PreserveDebug
|
||||||
|
)
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Starting dashboard..." -ForegroundColor Yellow
|
Write-Host " Starting dashboard..." -ForegroundColor Yellow
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
@@ -1777,6 +1781,22 @@ print(json.dumps(s))
|
|||||||
}
|
}
|
||||||
$settings = $settingsJson | ConvertFrom-Json
|
$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
|
$ServerHost = $settings.server.host
|
||||||
$SSHUser = $settings.server.user
|
$SSHUser = $settings.server.user
|
||||||
$LocalPort = [int]$settings.database.port
|
$LocalPort = [int]$settings.database.port
|
||||||
@@ -2172,6 +2192,19 @@ function Start-DashboardDebug {
|
|||||||
Write-Host " Starting Dashboard with DEBUG LOGGING enabled" -ForegroundColor Magenta
|
Write-Host " Starting Dashboard with DEBUG LOGGING enabled" -ForegroundColor Magenta
|
||||||
Write-Host " ============================================================" -ForegroundColor Magenta
|
Write-Host " ============================================================" -ForegroundColor Magenta
|
||||||
Write-Host ""
|
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
|
# Check Python
|
||||||
if (-not (Test-Python)) {
|
if (-not (Test-Python)) {
|
||||||
@@ -2250,8 +2283,8 @@ print('ok')
|
|||||||
Write-Host " Continuing with dashboard startup..." -ForegroundColor Yellow
|
Write-Host " Continuing with dashboard startup..." -ForegroundColor Yellow
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# Now start the dashboard (reuses all the same logic)
|
# Now start the dashboard (reuses all the same logic but preserve debug)
|
||||||
Start-Dashboard
|
Start-Dashboard -PreserveDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── Main Loop ───────────────────────────────────────────────────────────
|
# ── Main Loop ───────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in new issue
Block a user