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

Breadcrumb

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

function Logger::__construct

Same name in this branch
  1. 11.1.x vendor/open-telemetry/sdk/Logs/Logger.php \OpenTelemetry\SDK\Logs\Logger::__construct()

Parameters

string|resource|null $output:

File

vendor/symfony/http-kernel/Log/Logger.php, line 60

Class

Logger
Minimalist PSR-3 logger designed to write in stderr or any other stream.

Namespace

Symfony\Component\HttpKernel\Log

Code

public function __construct(?string $minLevel = null, $output = null, ?callable $formatter = null, ?RequestStack $requestStack = null, bool $debug = false) {
    if (null === $minLevel) {
        $minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
        if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
            $minLevel = match ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {    -1 => LogLevel::ERROR,
                1 => LogLevel::NOTICE,
                2 => LogLevel::INFO,
                3 => LogLevel::DEBUG,
                default => $minLevel,
            
            };
        }
    }
    if (!isset(self::LEVELS[$minLevel])) {
        throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $minLevel));
    }
    $this->minLevelIndex = self::LEVELS[$minLevel];
    $this->formatter = null !== $formatter ? $formatter(...) : $this->format(...);
    if ($output && false === ($this->handle = \is_string($output) ? @fopen($output, 'a') : $output)) {
        throw new InvalidArgumentException(\sprintf('Unable to open "%s".', $output));
    }
    $this->debug = $debug;
}

API Navigation

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