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

Breadcrumb

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

class Logging

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/Logging/Logging.php \PHPUnit\TextUI\XmlConfiguration\Logging\Logging

Logging utility functions for internal logging (of OpenTelemetry errors/warnings etc). This is not part of SDK configuration to avoid creating a dependency on SDK from any package which does logging. @todo this should be `@internal`, but deptrac is not happy with that.

Hierarchy

  • class \OpenTelemetry\API\Behavior\Internal\Logging

Expanded class hierarchy of Logging

1 file declares its use of Logging
LogsMessagesTrait.php in vendor/open-telemetry/api/Behavior/LogsMessagesTrait.php
5 string references to 'Logging'
Cron::invokeCronHandlers in core/lib/Drupal/Core/Cron.php
Invokes any cron handlers implementing hook_cron.
CronForm::buildForm in core/modules/system/src/Form/CronForm.php
Form constructor.
SearchController::view in core/modules/search/src/Controller/SearchController.php
Creates a render array for the search page.
SearchPageListBuilder::buildForm in core/modules/search/src/SearchPageListBuilder.php
Form constructor.
SearchPageListBuilder::buildForm in core/modules/search/src/SearchPageListBuilder.php
Form constructor.

File

vendor/open-telemetry/api/Behavior/Internal/Logging.php, line 16

Namespace

OpenTelemetry\API\Behavior\Internal
View source
class Logging {
    private const OTEL_LOG_LEVEL = 'OTEL_LOG_LEVEL';
    private const DEFAULT_LEVEL = LogLevel::INFO;
    private const NONE = 'none';
    private const LEVELS = [
        LogLevel::DEBUG,
        LogLevel::INFO,
        LogLevel::NOTICE,
        LogLevel::WARNING,
        LogLevel::ERROR,
        LogLevel::CRITICAL,
        LogLevel::ALERT,
        LogLevel::EMERGENCY,
        self::NONE,
    ];
    
    /**
     * The minimum log level. Messages with lower severity than this will be ignored.
     */
    private static ?int $logLevel = null;
    private static ?LogWriterInterface $writer = null;
    public static function setLogWriter(LogWriterInterface $writer) : void {
        self::$writer = $writer;
    }
    public static function logWriter() : LogWriterInterface {
        self::$writer ??= (new LogWriterFactory())->create();
        return self::$writer;
    }
    
    /**
     * Get level priority from level name
     */
    public static function level(string $level) : int {
        $value = array_search($level, self::LEVELS);
        return $value ?: 1;
        
        //'info'
    }
    
    /**
     * Get defined OTEL_LOG_LEVEL, or default
     */
    public static function logLevel() : int {
        self::$logLevel ??= self::getLogLevel();
        return self::$logLevel;
    }
    private static function getLogLevel() : int {
        $level = array_key_exists(self::OTEL_LOG_LEVEL, $_SERVER) ? $_SERVER[self::OTEL_LOG_LEVEL] : getenv(self::OTEL_LOG_LEVEL);
        if (!$level) {
            $level = ini_get(self::OTEL_LOG_LEVEL);
        }
        if (!$level) {
            $level = self::DEFAULT_LEVEL;
        }
        return self::level($level);
    }
    public static function reset() : void {
        self::$logLevel = null;
        self::$writer = null;
    }
    public static function disable() : void {
        self::$writer = new NoopLogWriter();
    }

}

Members

Title Sort descending Modifiers Object type Summary
Logging::$logLevel private static property The minimum log level. Messages with lower severity than this will be ignored.
Logging::$writer private static property
Logging::DEFAULT_LEVEL private constant
Logging::disable public static function
Logging::getLogLevel private static function
Logging::level public static function Get level priority from level name
Logging::LEVELS private constant
Logging::logLevel public static function Get defined OTEL_LOG_LEVEL, or default
Logging::logWriter public static function
Logging::NONE private constant
Logging::OTEL_LOG_LEVEL private constant
Logging::reset public static function
Logging::setLogWriter public static function

API Navigation

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