Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConsoleLogger.php

function ConsoleLogger::log

File

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

Class

ConsoleLogger
PSR-3 compliant console logger.

Namespace

Symfony\Component\Console\Logger

Code

public function log($level, $message, array $context = []) : void {
    if (!isset($this->verbosityLevelMap[$level])) {
        throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level));
    }
    $output = $this->output;
    // Write to the error output if necessary and available
    if (self::ERROR === $this->formatLevelMap[$level]) {
        if ($this->output instanceof ConsoleOutputInterface) {
            $output = $output->getErrorOutput();
        }
        $this->errored = true;
    }
    // the if condition check isn't necessary -- it's the same one that $output will do internally anyway.
    // We only do it for efficiency here as the message formatting is relatively expensive.
    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)), $this->verbosityLevelMap[$level]);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal