PluginProbe
404 Solution / 4.3.0
404 Solution v4.3.0
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 4.3.0, at includes/core/PhpErrorLogFallback.php

38 lines 1.2 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 if (!function_exists('abj404_logPhpFallback')) {
8 /**
9 * Emit a last-resort PHP error-log breadcrumb when plugin logging is
10 * unavailable or unsafe to call.
11 *
12 * This is the only production sink for raw error_log(). Normal code should
13 * attempt the plugin logger first, then call this helper only for the final
14 * PHP-log fallback path.
15 *
16 * @param string $category One of the audit categories for fallback logging.
17 * @param string $message Human-readable diagnostic context.
18 * @return void
19 */
20 function abj404_logPhpFallback(string $category, string $message): void {
21 $allowedCategories = array(
22 'early-boot',
23 'logger-internal',
24 'service-resolution-fallback',
25 'fatal-handler-fallback',
26 'transport-fallback',
27 );
28
29 $normalizedCategory = in_array($category, $allowedCategories, true)
30 ? $category
31 : 'uncategorized:' . $category;
32 $normalizedMessage = str_replace(array("\r", "\n"), ' ', $message);
33
34 // @abj404-raw-error-log-allowed: logger-internal centralized PHP error-log fallback is the single approved raw sink when plugin logging is unavailable.
35 @error_log('404 Solution: ' . $normalizedMessage . ' [' . $normalizedCategory . ']');
36 }
37 }
38