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:
@@ -6,6 +6,7 @@ namespace LIT\MCP\Abilities;
|
||||
|
||||
use LIT\MCP\Access;
|
||||
use LIT\MCP\Integrations\IntegrationRegistry;
|
||||
use LIT\MCP\Log;
|
||||
use LIT\MCP\Server\RequestContext;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
@@ -64,8 +65,7 @@ final class AbilityRegistrar
|
||||
try {
|
||||
return $ability->permission(is_array($input) ? $input : []);
|
||||
} catch (Throwable $e) {
|
||||
$message = sprintf('[wp-lit-mcp] %s failed: %s', $ability->name(), $e);
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure($ability->name(), $e);
|
||||
return Errors::internal();
|
||||
}
|
||||
},
|
||||
@@ -73,12 +73,10 @@ final class AbilityRegistrar
|
||||
try {
|
||||
return $ability->execute(is_array($input) ? $input : []);
|
||||
} catch (WriteFailed $e) {
|
||||
$message = sprintf('[wp-lit-mcp] %s failed: %s', $ability->name(), $e);
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure($ability->name(), $e);
|
||||
return $e->toError();
|
||||
} catch (Throwable $e) {
|
||||
$message = sprintf('[wp-lit-mcp] %s failed: %s', $ability->name(), $e);
|
||||
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
||||
Log::failure($ability->name(), $e);
|
||||
return Errors::internal();
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user