:`. * @param string $status succeeded, skipped or failed. * @param string $message The line shown on the entry ("Mailchimp: subscribed"). * @param array $data Details (no secrets). */ public static function record( int $submissionId, string $service, string $stepId, string $status, string $message, array $data = array() ): void { if ( $submissionId <= 0 ) { return; } $failed = 'failed' === $status; $data = array_merge( array( 'summary' => $message ), $data ); try { ( new LogsRepository() )->create( array( 'submission_id' => $submissionId, 'level' => $failed ? 'error' : ( 'skipped' === $status ? 'warning' : 'info' ), 'message' => $message, 'context' => array( 'submission_id' => $submissionId, 'step_id' => $stepId, 'action_type' => $service, 'status' => $status, 'data' => $data, 'error' => $failed ? (string) ( $data['error'] ?? '' ) : null, 'ts' => time(), ), ) ); } catch ( \Throwable $e ) { Logger::error( 'Could not write the %s line for entry %d: %s', $service, $submissionId, $e->getMessage() ); } } }