You are here

public function ConsoleLogger::log in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Logger/ConsoleLogger.php \Symfony\Component\Console\Logger\ConsoleLogger::log()

Logs with an arbitrary level.

Parameters

mixed $level:

string $message:

array $context:

Return value

null

Overrides LoggerInterface::log

File

vendor/symfony/console/Logger/ConsoleLogger.php, line 78

Class

ConsoleLogger
PSR-3 compliant console logger.

Namespace

Symfony\Component\Console\Logger

Code

public function log($level, $message, array $context = array()) {
  if (!isset($this->verbosityLevelMap[$level])) {
    throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  }

  // Write to the error output if necessary and available
  if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) {
    $output = $this->output
      ->getErrorOutput();
  }
  else {
    $output = $this->output;
  }
  if ($output
    ->getVerbosity() >= $this->verbosityLevelMap[$level]) {
    $output
      ->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this
      ->interpolate($message, $context)));
  }
}