diff --git a/Service/LoggerService.php b/Service/LoggerService.php index e85aae9..93c742c 100644 --- a/Service/LoggerService.php +++ b/Service/LoggerService.php @@ -151,6 +151,7 @@ class LoggerService $traces = 0; foreach ($backtraces as $trace) { $skip = false; + // Applying the filters, $skip if match is found foreach ($classFilters as $class) { if (strpos($trace['class'], $class)) { $skip = true; @@ -159,6 +160,7 @@ class LoggerService if ($skip) { continue; } + // Save the function and class of this level $context[] = "function[$traces]: ".$trace['function']; $context[] = "class[$traces]: ".$trace['class']; ++$traces; @@ -167,7 +169,15 @@ class LoggerService return $context; } - public function getLatest($amount = 1, $level = self::DEBUG) + /** + * Get the latest log entry limited by $limit and of at least log level $level. + * + * @param int $limit The maximum amount of entries + * @param int $level The minimum log level for the entries + * + * @return mixed + */ + public function getLatest($limit = 1, $level = self::DEBUG) { $qb = $this->em->createQueryBuilder(); @@ -177,7 +187,7 @@ class LoggerService ->where($qb->expr()->gte('l.level', '?1')) ->orderBy('l.createdAt', 'DESC') ->setParameter(1, $level) - ->setMaxResults($amount); + ->setMaxResults($limit); return $qb->getQuery()->getResult(); }