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

Breadcrumb

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

class LogRecord

Same name in this branch
  1. 11.1.x vendor/open-telemetry/gen-otlp-protobuf/Opentelemetry/Proto/Logs/V1/LogRecord.php \Opentelemetry\Proto\Logs\V1\LogRecord

Hierarchy

  • class \OpenTelemetry\API\Logs\LogRecord

Expanded class hierarchy of LogRecord

3 files declare their use of LogRecord
EventLogger.php in vendor/open-telemetry/sdk/Logs/EventLogger.php
Logger.php in vendor/open-telemetry/sdk/Logs/Logger.php
ReadableLogRecord.php in vendor/open-telemetry/sdk/Logs/ReadableLogRecord.php

File

vendor/open-telemetry/api/Logs/LogRecord.php, line 9

Namespace

OpenTelemetry\API\Logs
View source
class LogRecord {
    public const NANOS_PER_SECOND = 1000000000;
    protected ?int $timestamp = null;
    protected ?int $observedTimestamp = null;
    protected ?ContextInterface $context = null;
    protected int $severityNumber = 0;
    protected ?string $severityText = null;
    protected array $attributes = [];
    public function __construct(mixed $body = null) {
    }
    
    /**
     * @param int $timestamp Timestamp, in nanoseconds since the unix epoch, when the event occurred.
     * @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-timestamp
     */
    public function setTimestamp(int $timestamp) : self {
        $this->timestamp = $timestamp;
        return $this;
    }
    public function setContext(?ContextInterface $context = null) : self {
        $this->context = $context;
        return $this;
    }
    
    /**
     * @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-severitynumber
     */
    public function setSeverityNumber(Severity|int $severityNumber) : self {
        $this->severityNumber = $severityNumber instanceof Severity ? $severityNumber->value : $severityNumber;
        return $this;
    }
    
    /**
     * @param string $severityText Severity text, also known as log level
     * @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-severitynumber
     */
    public function setSeverityText(string $severityText) : self {
        $this->severityText = $severityText;
        return $this;
    }
    
    /**
     * @param iterable $attributes Additional information about the specific event occurrence.
     * @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-attributes
     */
    public function setAttributes(iterable $attributes) : self {
        foreach ($attributes as $name => $value) {
            $this->setAttribute($name, $value);
        }
        return $this;
    }
    public function setAttribute(string $name, mixed $value) : self {
        $this->attributes[$name] = $value;
        return $this;
    }
    
    /**
     * @param mixed $body The log record body
     */
    public function setBody(mixed $body = null) : self {
        $this->body = $body;
        return $this;
    }
    
    /**
     * @param int|null $observedTimestamp Time, in nanoseconds since the unix epoch, when the event was observed by the collection system.
     */
    public function setObservedTimestamp(?int $observedTimestamp = null) : self {
        $this->observedTimestamp = $observedTimestamp;
        return $this;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
LogRecord::$attributes protected property
LogRecord::$context protected property
LogRecord::$observedTimestamp protected property
LogRecord::$severityNumber protected property
LogRecord::$severityText protected property
LogRecord::$timestamp protected property
LogRecord::NANOS_PER_SECOND public constant
LogRecord::setAttribute public function
LogRecord::setAttributes public function
LogRecord::setBody public function
LogRecord::setContext public function
LogRecord::setObservedTimestamp public function
LogRecord::setSeverityNumber public function
LogRecord::setSeverityText public function
LogRecord::setTimestamp public function
LogRecord::__construct public function 1

API Navigation

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