Skip to content
PHP Ecosystem
Explore

PsrMessage

API reference › yii › log › PsrMessage

final readonly classyii\log\PsrMessage
ImplementsStringable
Since22.0
Sourceframework/log/PsrMessage.php

Stores a PSR-3 message together with its original level and context.

String conversion performs the optional PSR-3 placeholder interpolation while ignoring context values that cannot be safely converted to strings.

MethodDescriptionDefined by
__construct()PsrMessage
__toString()Returns the message with safely convertible context placeholders interpolated.PsrMessage
getContext()Returns the PSR-3 context.PsrMessage
getLevel()Returns the original PSR-3 level.PsrMessage
getMessage()Returns the message without placeholder interpolation.PsrMessage
public function __construct(string|Stringable $message, array<array-key, mixed> $context, string $level)

Parameters

ParameterTypeDescription
$messagestring|StringableThe PSR-3 message, cast to string eagerly so a throwing Stringable fails at the logging call site instead of during a later target flush.
$contextarray<array-key, mixed>The PSR-3 context.
$levelstringThe original PSR-3 level.
public function __toString(): string

Returns the message with safely convertible context placeholders interpolated.

Returns

string

public function getContext(): array<array-key, mixed>

Returns the PSR-3 context.

Returns

array<array-key, mixed>

public function getLevel(): string

Returns the original PSR-3 level.

Returns

string

public function getMessage(): string

Returns the message without placeholder interpolation.

Returns

string