# 404-solution/4.3.0/includes/logs/LogDebugModeResolver.php

404 Solution, version 4.3.0. 55 lines.

- Page: https://pluginprobe.com/plugins/404-solution/4.3.0/code/includes/logs/LogDebugModeResolver.php
- Raw: https://pluginprobe.com/plugins/404-solution/4.3.0/raw/includes/logs/LogDebugModeResolver.php
- Modified: 2026-06-23T05:55:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/404-solution/4.3.0/code/includes/logs/LogDebugModeResolver.php#L10-L20`.

```php
<?php

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Decides whether debug logging is currently enabled.
 *
 * Resolution order: an in-memory PluginLogic `options['debug_mode']` override
 * (read reflectively so an early-boot caller that has populated PluginLogic but
 * not yet wired the options repository still gets the right answer) takes
 * precedence; otherwise the canonical answer comes from the options repository.
 *
 * Pure policy: reads configuration, makes one boolean decision, writes nothing.
 */
class ABJ_404_Solution_LogDebugModeResolver {

    /** @return bool true if debug mode is on. false otherwise. */
    public function isDebug(): bool {
        $legacyDebugMode = $this->legacyPluginLogicDebugMode();
        if ($legacyDebugMode !== null) {
            return $legacyDebugMode;
        }

        $options = abj_service('options_repository')->getOptions(true);

        return (array_key_exists('debug_mode', $options) && $options['debug_mode'] == true);
    }

    /** @return bool|null */
    private function legacyPluginLogicDebugMode(): ?bool {
        if (!class_exists('ABJ_404_Solution_PluginLogic', false)) {
            return null;
        }
        $pluginLogic = ABJ_404_Solution_PluginLogic::peekInstance();
        if (!is_object($pluginLogic)) {
            return null;
        }
        try {
            $optionsProperty = new ReflectionProperty('ABJ_404_Solution_PluginLogic', 'options');
            $options = $optionsProperty->getValue($pluginLogic);
            if (is_array($options) && array_key_exists('debug_mode', $options)) {
                return $options['debug_mode'] == true;
            }
        } catch (\Throwable $e) {
            abj404_logPhpFallback(
                'logger-internal',
                'could not inspect PluginLogic debug_mode override: ' . $e->getMessage()
            );
        }
        return null;
    }
}

```
