Final Class Yiisoft\Log\ContextProvider\SystemContextProvider
| Inheritance | Yiisoft\Log\ContextProvider\SystemContextProvider |
|---|---|
| Implements | Yiisoft\Log\ContextProvider\ContextProviderInterface |
Public 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
| 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);
}
| 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,
];
}
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;
}
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;
}
Signup or Login in order to comment.