refactor: one logging helper LIT\MCP\Log (M6)
Log::failure(context, detail) keeps the '[wp-lit-mcp] <context> failed: <detail>' format of the nine former error_log() sites; Log::line() covers the change log line. One phpcs ignore instead of eleven. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Parser;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use LIT\MCP\Log;
|
||||
use WP_Error;
|
||||
use WP_Post;
|
||||
|
||||
@@ -51,8 +52,7 @@ class DiviPageLoader
|
||||
try {
|
||||
$document = $this->parser->parse($content);
|
||||
} catch (MalformedMarkup $e) {
|
||||
$message = sprintf('[wp-lit-mcp] divi parse of post %d failed: %s', $post->ID, $e->getMessage());
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure(sprintf('divi parse of post %d', $post->ID), $e->getMessage());
|
||||
|
||||
return Errors::unsupported(
|
||||
sprintf(
|
||||
|
||||
@@ -15,6 +15,7 @@ use LIT\MCP\Integrations\Divi\BlockTree\Serializer;
|
||||
use LIT\MCP\Integrations\Divi\Compose\TextReplacer;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use LIT\MCP\Log;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
|
||||
@@ -484,8 +485,7 @@ final class DiviReplaceTextAbility implements Ability
|
||||
|
||||
private static function log(int $postId, Throwable $e): void
|
||||
{
|
||||
$message = sprintf('[wp-lit-mcp] lit/divi-replace-text on post %d failed: %s', $postId, $e);
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure(sprintf('lit/divi-replace-text on post %d', $postId), $e);
|
||||
}
|
||||
|
||||
private function db(): \wpdb
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace LIT\MCP\Integrations\Divi\Pages;
|
||||
use Closure;
|
||||
use LIT\MCP\Integrations\Divi\Compose\Placeholders;
|
||||
use LIT\MCP\Integrations\Divi\Compose\VariableRef;
|
||||
use LIT\MCP\Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -43,12 +44,7 @@ class DynamicContentMap
|
||||
try {
|
||||
$options = $this->registry !== null ? ($this->registry)($postId) : self::divi($postId);
|
||||
} catch (Throwable $e) {
|
||||
$message = sprintf(
|
||||
'[wp-lit-mcp] divi dynamic content options of post %d failed: %s',
|
||||
$postId,
|
||||
$e->getMessage()
|
||||
);
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure(sprintf('divi dynamic content options of post %d', $postId), $e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user