package com.hubilon.util; import java.util.List; /** * Shared debug-logging state. The -DebugLog equivalent switch always wins; * config-driven debug/secret values only take effect from the first * /config request onward, mirroring run.ps1. */ public final class DebugState { private final boolean debugFromSwitch; private volatile boolean debugFromConfig = false; private volatile List secrets = List.of(); public DebugState(boolean debugFromSwitch) { this.debugFromSwitch = debugFromSwitch; } public boolean isEnabled() { return debugFromSwitch || debugFromConfig; } public void updateFromConfig(boolean configDebug, List secretValues) { this.debugFromConfig = configDebug; this.secrets = secretValues; } public List getSecrets() { return secrets; } public void log(String category, String message) { if (!isEnabled()) { return; } String masked = SensitiveHeaders.maskSecrets(message, secrets); System.out.println("[" + category + "] " + masked); } }