| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
require_once __DIR__ . '/PhpRuntimeCapabilityAdapter.php'; |
| 8 |
|
| 9 |
if (!function_exists('abj404_logPhpFallback')) { |
| 10 |
/** |
| 11 |
* Emit a last-resort PHP error-log breadcrumb when plugin logging is |
| 12 |
* unavailable or unsafe to call. |
| 13 |
* |
| 14 |
* This is the only application-level PHP-log fallback. Normal code should |
| 15 |
* attempt the plugin logger first, then call this helper only for the final |
| 16 |
* fallback path. The runtime adapter owns the raw, capability-checked call. |
| 17 |
* |
| 18 |
* @param string $category One of the audit categories for fallback logging. |
| 19 |
* @param string $message Human-readable diagnostic context. |
| 20 |
* @return void |
| 21 |
*/ |
| 22 |
function abj404_logPhpFallback(string $category, string $message): void { |
| 23 |
$allowedCategories = array( |
| 24 |
'early-boot', |
| 25 |
'logger-internal', |
| 26 |
'service-resolution-fallback', |
| 27 |
'fatal-handler-fallback', |
| 28 |
'transport-fallback', |
| 29 |
); |
| 30 |
|
| 31 |
$normalizedCategory = in_array($category, $allowedCategories, true) |
| 32 |
? $category |
| 33 |
: 'uncategorized:' . $category; |
| 34 |
$normalizedMessage = str_replace(array("\r", "\n"), ' ', $message); |
| 35 |
|
| 36 |
ABJ_404_Solution_PhpRuntimeCapabilityAdapter::writeErrorLog( |
| 37 |
'404 Solution: ' . $normalizedMessage . ' [' . $normalizedCategory . ']' |
| 38 |
); |
| 39 |
} |
| 40 |
} |
| 41 |
|