PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / core / PhpErrorLogFallback.php

PhpErrorLogFallback.php in 404 Solution trunk, at includes/core/PhpErrorLogFallback.php

41 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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