<commit_before>package com.gu.notifications.worker.utils

import cats.effect.IO
import com.gu.notifications.worker.delivery.{DeliveryClient, DeliveryException, DeliverySuccess}
import org.slf4j.Logger

object Reporting {

  def log[C <: DeliveryClient](prefix: String)(implicit logger: Logger): Either[DeliveryException, DeliverySuccess] => IO[Unit] = { resp =>
    IO.delay {
      resp match {
        case Left(e) => logger.error(s"$prefix $e")
        case Right(_) => () // doing nothing when success<commit_msg>only mark invalid tokens as warning<commit_after>package com.gu.notifications.worker.utils

import cats.effect.IO
import com.gu.notifications.worker.delivery.DeliveryException.InvalidToken
import com.gu.notifications.worker.delivery.{DeliveryClient, DeliveryException, DeliverySuccess}
import org.slf4j.Logger

object Reporting {

  def log[C <: DeliveryClient](prefix: String)(implicit logger: Logger): Either[DeliveryException, DeliverySuccess] => IO[Unit] = { resp =>
    IO.delay {
      resp match {
        case Left(e: InvalidToken) => logger.warn(s"$prefix $e")
        case Left(e) => logger.error(s"$prefix $e")
        case Right(_) => () // doing nothing when success
{'fraction_non_alphanumeric': 0.12374581939799331, 'fraction_numerical': 0.0016722408026755853, 'mean_word_length': 4.516129032258065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7594395', 'n_tokens_mistral': 358, 'n_tokens_neox': 345, 'n_words': 81}