App src code
This commit is contained in:
44
app/common/Service/Logs.php
Normal file
44
app/common/Service/Logs.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace ProVM\Common\Service;
|
||||
|
||||
use ProVM\Logview\Log\File;
|
||||
|
||||
class Logs
|
||||
{
|
||||
public function __construct(string $folder)
|
||||
{
|
||||
$this
|
||||
->setFolder($folder);
|
||||
}
|
||||
|
||||
protected string $folder;
|
||||
|
||||
public function getFolder(): string
|
||||
{
|
||||
return $this->folder;
|
||||
}
|
||||
|
||||
public function setFolder(string $folder): Logs
|
||||
{
|
||||
$this->folder = $folder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFiles(): array
|
||||
{
|
||||
$files = new \FilesystemIterator($this->getFolder());
|
||||
$output = [];
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
$output []= $file;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
public function get(string $log_file): File
|
||||
{
|
||||
$content = \Safe\file_get_contents(implode(DIRECTORY_SEPARATOR, [$this->getFolder(), $log_file]));
|
||||
return (new File())->setFilename($log_file)->setContent($content);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user