0 follower

Final Class Yiisoft\Profiler\Message

InheritanceYiisoft\Profiler\Message

Message is a data object that stores profile message data.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Profiler\Message
context() Returns a value of the context parameter for the specified name. Yiisoft\Profiler\Message
level() Gets a message level. Yiisoft\Profiler\Message
token() Gets a message token. Yiisoft\Profiler\Message

Method Details

Hide inherited methods

__construct() public method

See also:

  • \Psr\Log\LoggerTrait::log()
  • \Psr\Log\LogLevel
public mixed __construct ( string $level, string $token, array $context = [] )
$level string

Message level.

$token string

Message token.

$context array

Message context with a following keys:

  • category: string, message category.
  • memory: int, memory usage in bytes, obtained by memory_get_usage().
  • time: float, message timestamp obtained by microtime(true).
  • trace: array, debug backtrace, contains the application code call stacks.
throws \Psr\Log\InvalidArgumentException

for invalid log message level.

                public function __construct(
    private readonly string $level,
    private readonly string $token,
    private readonly array $context = [],
) {
}

            
context() public method

Returns a value of the context parameter for the specified name.

If no name is specified, the entire context is returned.

public mixed context ( string|null $name null, mixed $default null )
$name string|null

The context parameter name.

$default mixed

If the context parameter does not exist, the $default will be returned.

                public function context(?string $name = null, mixed $default = null): mixed
{
    if ($name === null) {
        return $this->context;
    }
    /** @var array<array-key, mixed> */
    return $this->context[$name] ?? $default;
}

            
level() public method

Gets a message level.

public string level ( )
return string

Log message level.

                public function level(): string
{
    return $this->level;
}

            
token() public method

Gets a message token.

public string token ( )
return string

Message token.

                public function token(): string
{
    return $this->token;
}