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

Breadcrumb

  1. Drupal Core 11.1.x

LoggerAwareTrait.php

Same filename in this branch
  1. 11.1.x vendor/psr/log/src/LoggerAwareTrait.php

Namespace

OpenTelemetry\SDK\Trace\Behavior

File

vendor/open-telemetry/sdk/Trace/Behavior/LoggerAwareTrait.php

View source
<?php

declare (strict_types=1);
namespace OpenTelemetry\SDK\Trace\Behavior;

use Psr\Log\LoggerAwareTrait as PsrTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
trait LoggerAwareTrait {
    use PsrTrait;
    private string $defaultLogLevel = LogLevel::INFO;
    public function setDefaultLogLevel(string $logLevel) : void {
        $this->defaultLogLevel = $logLevel;
    }
    protected function log(string $message, array $context = [], ?string $level = null) : void {
        $this->getLogger()
            ->log($level ?? $this->defaultLogLevel, $message, $context);
    }
    protected function getLogger() : LoggerInterface {
        if ($this->logger !== null) {
            return $this->logger;
        }
        return new NullLogger();
    }

}

Traits

Title Deprecated Summary
LoggerAwareTrait

API Navigation

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