$this->warning('A possible infinite logging loop was detected and aborted. It appears some of your handler code is triggering logging, see the previous log record for a hint as to what may be the cause.');
returnfalse;
}elseif($logDepth>=5){// log depth 4 is let through, so we can log the warning above
returnfalse;
}
try{
$record=null;
foreach($this->handlersas$handler){
if(null===$record){
// skip creating the record as long as no handler is going to handle it
thrownewInvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ',array_keys(static::$levels)+static::$levels));
}
if(!is_int($level)){
thrownewInvalidArgumentException('Level "'.var_export($level,true).'" is not defined, use one of: '.implode(', ',array_keys(static::$levels)+static::$levels));
}
return$level;
}
/**
* Checks whether the Logger has a handler that listens on the given level
*
* @phpstan-param Level $level
*/
publicfunctionisHandling(int$level):bool
{
$record=[
'level'=>$level,
];
foreach($this->handlersas$handler){
if($handler->isHandling($record)){
returntrue;
}
}
returnfalse;
}
/**
* Set a custom exception handler that will be called if adding a new record fails
*
* The callable will receive an exception object and the record that failed to be logged