Skip to content

Commit

Permalink
FileLoggerInterface.getLastLine
Browse files Browse the repository at this point in the history
  • Loading branch information
ariademur committed Sep 3, 2021
1 parent abd39ca commit 064e0b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/WebServCo/Framework/Log/AbstractFileLogger.php
Expand Up @@ -6,7 +6,7 @@

use WebServCo\Framework\Exceptions\LoggerException;

abstract class AbstractFileLogger extends AbstractLogger
abstract class AbstractFileLogger extends AbstractLogger implements \WebServCo\Framework\Interfaces\FileLoggerInterface
{
protected string $channel;
protected string $logDir;
Expand All @@ -31,4 +31,11 @@ public function clear(): bool
{
return (bool) \file_put_contents($this->logPath, null);
}

public function getLastLine(): int
{
$file = new \SplFileObject($this->logPath, 'r');
$file->seek(\PHP_INT_MAX);
return $file->key();
}
}
4 changes: 2 additions & 2 deletions src/WebServCo/Framework/Processors/AbstractErrorProcessor.php
Expand Up @@ -5,14 +5,14 @@
namespace WebServCo\Framework\Processors;

use WebServCo\Framework\Helpers\ErrorMessageHelper;
use WebServCo\Framework\Interfaces\LoggerInterface;
use WebServCo\Framework\Interfaces\FileLoggerInterface;

/**
* A helper class for logging exceptions to a standard error(CLI) log file.
*/
abstract class AbstractErrorProcessor implements \WebServCo\Framework\Interfaces\ErrorProcessorInterface
{
protected LoggerInterface $fileLogger;
protected FileLoggerInterface $fileLogger;

abstract public function report(\Throwable $exception, ?string $reference = null): bool;

Expand Down

0 comments on commit 064e0b4

Please sign in to comment.