You are here

public function TransformerFactory::flushTransformerLogs in Facebook Instant Articles 3.x

Flush the logs for the given Transformer instance if any.

@todo This is kind of conflating the responsibility of this class. Consider breaking it out into it's own service.

Parameters

\Facebook\InstantArticles\Transformer\Transformer $transformer: A Transformer instance that may or may not have log output.

File

src/TransformerFactory.php, line 88

Class

TransformerFactory
Factory class for creating Transformer objects.

Namespace

Drupal\fb_instant_articles

Code

public function flushTransformerLogs(Transformer $transformer) {
  $level_map = [
    TransformerLog::DEBUG => LogLevel::DEBUG,
    TransformerLog::ERROR => LogLevel::ERROR,
    TransformerLog::INFO => LogLevel::INFO,
  ];
  if ($logs = $transformer
    ->getLogs()) {
    foreach ($logs as $log) {
      $this->logger
        ->log($level_map[$log
        ->getLevel()], $log
        ->getMessage());
    }
  }
}