0 follower

Final Class Yiisoft\Log\ContextProvider\SystemContextProvider

InheritanceYiisoft\Log\ContextProvider\SystemContextProvider
ImplementsYiisoft\Log\ContextProvider\ContextProviderInterface

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Log\ContextProvider\SystemContextProvider
getContext() Yiisoft\Log\ContextProvider\SystemContextProvider
setExcludedTracePaths() Sets an array of paths to exclude from tracing when tracing is enabled with {@see self::$traceLevel}. Yiisoft\Log\ContextProvider\SystemContextProvider
setTraceLevel() Sets how much call stack information (file name and line number) should be logged for each log message. Yiisoft\Log\ContextProvider\SystemContextProvider

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( integer $traceLevel 0, string[] $excludedTracePaths = [] )
$traceLevel integer

How much call stack information (file name and line number) should be logged for each log message. If it is greater than 0, at most that number of call stacks will be logged. Note that only application call stacks are counted.

$excludedTracePaths string[]

Array of paths to exclude from tracing when tracing is enabled with {@see $traceLevel}.

                public function __construct(
    private int $traceLevel = 0,
    array $excludedTracePaths = [],
) {
    /** @psalm-suppress DeprecatedMethod `setExcludedTracePaths` will be private and not deprecated */
    $this->setExcludedTracePaths($excludedTracePaths);
}

            
getContext() public method

public array getContext ( )

                public function getContext(): array
{
    /** @psalm-var list<TraceItem> $trace */
    $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    array_shift($trace);
    return [
        'time' => microtime(true),
        'trace' => $this->collectTrace($trace),
        'memory' => memory_get_usage(),
        'category' => Message::DEFAULT_CATEGORY,
    ];
}

            
setExcludedTracePaths() public method
Deprecated since 2.1.0, to be removed in 3.0.0. Use constructor parameter "excludedTracePaths" instead.

Sets an array of paths to exclude from tracing when tracing is enabled with {@see self::$traceLevel}.

See also \Yiisoft\Log\ContextProvider\self::$excludedTracePaths.

public self setExcludedTracePaths ( string[] $excludedTracePaths )
$excludedTracePaths string[]

The paths to exclude from tracing.

throws InvalidArgumentException

for non-string values.

                public function setExcludedTracePaths(array $excludedTracePaths): self
{
    foreach ($excludedTracePaths as $excludedTracePath) {
        /** @psalm-suppress DocblockTypeContradiction */
        if (!is_string($excludedTracePath)) {
            throw new InvalidArgumentException(
                sprintf(
                    'The trace path must be a string, %s received.',
                    get_debug_type($excludedTracePath)
                )
            );
        }
    }
    $this->excludedTracePaths = $excludedTracePaths;
    return $this;
}

            
setTraceLevel() public method
Deprecated since 2.1.0, to be removed in 3.0.0. Use constructor parameter "traceLevel" instead.

Sets how much call stack information (file name and line number) should be logged for each log message.

See also \Yiisoft\Log\ContextProvider\self::$traceLevel.

public self setTraceLevel ( integer $traceLevel )
$traceLevel integer

The number of call stack information.

                public function setTraceLevel(int $traceLevel): self
{
    $this->traceLevel = $traceLevel;
    return $this;
}