Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationStepLogger::log_failure
Records a failure as an error or warning under the module's own source, which is never switched off, and as a step in the notification's journey. The error line carries the same identifying fields as the step, so a store whose log threshold drops info still has a line the read path can join to the notification.
Where identifying the notification fails, the error line is still written, without those fields.
Method of the class: NotificationStepLogger{}
No Hooks.
Returns
void. Nothing (null).
Usage
$NotificationStepLogger = new NotificationStepLogger(); $NotificationStepLogger->log_failure( $notification, $step, $outcome, $level, $message, $context ): void;
- $notification(Notification) (required)
- The notification the failure belongs to.
- $step(string) (required)
- Machine-readable step name, e.g.
dispatched. - $outcome(string) (required)
- Machine-readable outcome, e.g.
request_failed. - $level(string) (required)
errororwarning.- $message(string) (required)
- Human-readable message for the error log.
- $context(array)
- Extra scalar fields to store with both lines.
Default:array()
Changelog
| Since 11.3.0 | Introduced. |
NotificationStepLogger::log_failure() NotificationStepLogger::log failure code WC 11.3.0
public function log_failure( Notification $notification, string $step, string $outcome, string $level, string $message, array $context = array() ): void {
try {
$identified = self::identify( $notification, $step, $outcome, $context );
} catch ( Throwable $e ) {
$this->log_unattributed_failure( $step, $outcome, $level, $message, $context );
return;
}
$this->write_error( $level, $message, $identified );
$this->log_notification_step( $notification, $step, $outcome, $context );
}