Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationStepLogger::write
Writes one line, swallowing any failure so logging can never break a send.
The source is built here rather than by the caller, because get_notification_source() runs sanitize_title() and its public filter.
Method of the class: NotificationStepLogger{}
No Hooks.
Returns
void. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->write( $notification, $step, $outcome, $context, $suppressed ): void;
- $notification(Notification) (required)
- The notification the step belongs to.
- $step(string) (required)
- Machine-readable step name.
- $outcome(string) (required)
- Machine-readable outcome.
- $context(array) (required)
- Extra fields to store with the line.
- $suppressed(true|false)
- True to write to the store-wide suppressed source instead of the notification type's.
Default:false
NotificationStepLogger::write() NotificationStepLogger::write code WC 11.3.0
private function write( Notification $notification, string $step, string $outcome, array $context, bool $suppressed = false ): void {
try {
if ( ! $this->is_active() ) {
return;
}
$context = self::bound( self::identify( $notification, $step, $outcome, $context ) );
$context['source'] = $suppressed
? self::SUPPRESSED_SOURCE
: self::get_notification_source( $notification );
wc_get_logger()->info( self::format_message( $step, $outcome ), $context );
} catch ( Throwable $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// Deliberately ignored: a logging failure must not affect the send.
}
}