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:
@@ -7,6 +7,7 @@ namespace LIT\MCP\Integrations\Media;
|
||||
use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\Limits;
|
||||
use LIT\MCP\Log;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
|
||||
@@ -197,8 +198,7 @@ class MediaImporter
|
||||
);
|
||||
if ($attachmentId instanceof WP_Error) {
|
||||
// WordPress' message can contain server paths: only for the log, not for the client.
|
||||
$message = sprintf('[wp-lit-mcp] media sideload failed: %s', $attachmentId->get_error_message());
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure('media sideload', $attachmentId->get_error_message());
|
||||
|
||||
return Errors::writeFailed(
|
||||
'WordPress hat die Datei nicht übernommen (z. B. Upload-Verzeichnis nicht beschreibbar).'
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Integrations\Media;
|
||||
|
||||
use Closure;
|
||||
use LIT\MCP\Log;
|
||||
|
||||
/**
|
||||
* Finds where an attachment is used (spec §6.3). Deliberately errs on the side of "used":
|
||||
@@ -165,8 +166,7 @@ class MediaUsageFinder
|
||||
}
|
||||
|
||||
$this->queryFailed = true;
|
||||
$message = sprintf('[wp-lit-mcp] media usage query failed: %s', (string) $wpdb->last_error);
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure('media usage query', (string) $wpdb->last_error);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user