16 private $backtrace_level;
24 public function __construct($level = Level::Warning, $backtrace_level = -1) {
25 $this->level = Logger::toMonologLevel($level);
26 $this->backtrace_level = $backtrace_level;
36 public function __invoke(LogRecord $record): LogRecord {
38 if ($record->level->isLowerThan($this->level)) {
42 $backtrace_level = $this->backtrace_level;
45 $backtrace = debug_backtrace();
47 $backtrace = array_slice($backtrace, 9);
49 $i =
count($backtrace);
51 foreach ($backtrace as $trace) {
52 if (empty($trace[
'file'])) {
54 $stack[] =
"[#$i] unknown";
56 $stack[] =
"[#$i] {$trace['file']}:{$trace['line']}";
61 if ($backtrace_level > 0) {
62 if ($backtrace_level <= 1) {
70 $record[
'extra'][
'backtrace'] = $stack;
Inject backtrace stack into the record.
__invoke(LogRecord $record)
Process record.
__construct($level=Level::Warning, $backtrace_level=-1)
Constructor.